<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FClass_Interface%2FClass_Variables</id>
		<title>Csharp/C Sharp/Class Interface/Class Variables - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FClass_Interface%2FClass_Variables"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Class_Interface/Class_Variables&amp;action=history"/>
		<updated>2026-04-29T21:19:53Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Class_Interface/Class_Variables&amp;diff=590&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Class_Interface/Class_Variables&amp;diff=590&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:18Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Class_Interface/Class_Variables&amp;diff=591&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Class_Interface/Class_Variables&amp;diff=591&amp;oldid=prev"/>
				<updated>2010-05-26T11:39:03Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==A Simple Class and Objects==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
public class Product {&lt;br /&gt;
    public string make;&lt;br /&gt;
    public string model;&lt;br /&gt;
    public string color;&lt;br /&gt;
    public int yearBuilt;&lt;br /&gt;
    public void Start() {&lt;br /&gt;
        System.Console.WriteLine(model + &amp;quot; started&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    public void Stop() {&lt;br /&gt;
        System.Console.WriteLine(model + &amp;quot; stopped&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
class MainClass{&lt;br /&gt;
    public static void Main() {&lt;br /&gt;
        Product myProduct;&lt;br /&gt;
        myProduct = new Product();&lt;br /&gt;
        myProduct.make = &amp;quot;Toyota&amp;quot;;&lt;br /&gt;
        myProduct.model = &amp;quot;MR2&amp;quot;;&lt;br /&gt;
        myProduct.color = &amp;quot;black&amp;quot;;&lt;br /&gt;
        myProduct.yearBuilt = 1995;&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;myProduct details:&amp;quot;);&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;myProduct.make = &amp;quot; + myProduct.make);&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;myProduct.model = &amp;quot; + myProduct.model);&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;myProduct.color = &amp;quot; + myProduct.color);&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;myProduct.yearBuilt = &amp;quot; + myProduct.yearBuilt);&lt;br /&gt;
        myProduct.Start();&lt;br /&gt;
        myProduct.Stop();&lt;br /&gt;
        Product redPorsche = new Product();&lt;br /&gt;
        redPorsche.make = &amp;quot;Porsche&amp;quot;;&lt;br /&gt;
        redPorsche.model = &amp;quot;Boxster&amp;quot;;&lt;br /&gt;
        redPorsche.color = &amp;quot;red&amp;quot;;&lt;br /&gt;
        redPorsche.yearBuilt = 2000;&lt;br /&gt;
        System.Console.WriteLine(          &amp;quot;redPorsche is a &amp;quot; + redPorsche.model);&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;Assigning redPorsche to myProduct&amp;quot;);&lt;br /&gt;
        myProduct = redPorsche;&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;myProduct details:&amp;quot;);&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;myProduct.make = &amp;quot; + myProduct.make);&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;myProduct.model = &amp;quot; + myProduct.model);&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;myProduct.color = &amp;quot; + myProduct.color);&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;myProduct.yearBuilt = &amp;quot; + myProduct.yearBuilt);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Class variables with default value==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Learning C# &lt;br /&gt;
by Jesse Liberty&lt;br /&gt;
Publisher: O&amp;quot;Reilly &lt;br /&gt;
ISBN: 0596003765&lt;br /&gt;
*/&lt;br /&gt;
 using System;&lt;br /&gt;
 public class MyTimeWithDefaultValue&lt;br /&gt;
 {&lt;br /&gt;
     // private member variables&lt;br /&gt;
     int year;&lt;br /&gt;
     int month;&lt;br /&gt;
     int date;&lt;br /&gt;
     int hour;&lt;br /&gt;
     int minute;&lt;br /&gt;
     int second = 30;&lt;br /&gt;
     // public method&lt;br /&gt;
     public void DisplayCurrentMyTimeWithDefaultValue()&lt;br /&gt;
     {&lt;br /&gt;
         System.Console.WriteLine(&amp;quot;{0}/{1}/{2} {3}:{4}:{5}&amp;quot;,&lt;br /&gt;
             month, date, year, hour, minute, second);&lt;br /&gt;
     }&lt;br /&gt;
     // constructor&lt;br /&gt;
     public MyTimeWithDefaultValue(int theYear, int theMonth, int theDate,&lt;br /&gt;
         int theHour, int theMinute)&lt;br /&gt;
     {&lt;br /&gt;
         year = theYear;&lt;br /&gt;
         month = theMonth;&lt;br /&gt;
         date = theDate;&lt;br /&gt;
         hour = theHour;&lt;br /&gt;
         minute = theMinute;&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 public class Tester&lt;br /&gt;
 {&lt;br /&gt;
     static void Main()&lt;br /&gt;
     {&lt;br /&gt;
         MyTimeWithDefaultValue timeObject = new MyTimeWithDefaultValue(2005,3,25,9,35);&lt;br /&gt;
         timeObject.DisplayCurrentMyTimeWithDefaultValue();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==declare a class Address containing the data members to describe a US address along with the member functions==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
using System;&lt;br /&gt;
class MainClass {&lt;br /&gt;
    public static void Main(string[] args) {&lt;br /&gt;
        Address addr = new Address();&lt;br /&gt;
        addr.SetStreet(123, &amp;quot;My Street&amp;quot;);&lt;br /&gt;
        addr.SetCity(&amp;quot;A&amp;quot;, &amp;quot;X&amp;quot;, 123456);&lt;br /&gt;
        Console.WriteLine(addr.GetStreetString());&lt;br /&gt;
        Console.WriteLine(addr.GetCityString());&lt;br /&gt;
        addr.Output();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Address {&lt;br /&gt;
    public int nAddressNumberPart;&lt;br /&gt;
    public string sAddressNamePart;&lt;br /&gt;
    public string sCity;&lt;br /&gt;
    public string sState;&lt;br /&gt;
    public int nPostalCode;&lt;br /&gt;
    public void SetStreet(int nNumber, string sName) {&lt;br /&gt;
        nAddressNumberPart = nNumber;&lt;br /&gt;
        sAddressNamePart = sName;&lt;br /&gt;
    }&lt;br /&gt;
    public string GetStreetString() {&lt;br /&gt;
        return nAddressNumberPart + &amp;quot; &amp;quot; + sAddressNamePart;&lt;br /&gt;
    }&lt;br /&gt;
    public void SetCity(string sCityIn, string sStateIn, int nPostalCodeIn) {&lt;br /&gt;
        sCity = sCityIn;&lt;br /&gt;
        sState = sStateIn;&lt;br /&gt;
        nPostalCode = nPostalCodeIn;&lt;br /&gt;
    }&lt;br /&gt;
    public string GetCityString() {&lt;br /&gt;
        return sCity + &amp;quot;, &amp;quot; + sState + &amp;quot; &amp;quot; + nPostalCode;&lt;br /&gt;
    }&lt;br /&gt;
    public string GetAddressString() {&lt;br /&gt;
        return GetStreetString() + &amp;quot;\n&amp;quot; + GetCityString();&lt;br /&gt;
    }&lt;br /&gt;
    public void Output() {&lt;br /&gt;
        Console.WriteLine(GetAddressString());&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Default Values of Class Member Variables==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
/*&lt;br /&gt;
    * bool types are set to false.&lt;br /&gt;
    * Numeric data is set to 0 (or 0.0 in the case of floating-point data types).&lt;br /&gt;
    * string types are set to null.&lt;br /&gt;
    * char types are set to &amp;quot;\0&amp;quot;.&lt;br /&gt;
    * Reference types are set to null.&lt;br /&gt;
Given these rules, ponder the following code:&lt;br /&gt;
*/&lt;br /&gt;
class Test &lt;br /&gt;
{ &lt;br /&gt;
     public int myInt;        // Set to 0. &lt;br /&gt;
     public string myString;  // Set to null. &lt;br /&gt;
     public bool myBool;      // Set to false. &lt;br /&gt;
     public object myObj;     // Set to null. &lt;br /&gt;
} &lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Field Attributes==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Reflection;&lt;br /&gt;
public enum RegHives {&lt;br /&gt;
    HKEY_CLASSES_ROOT,&lt;br /&gt;
    HKEY_CURRENT_USER,&lt;br /&gt;
    HKEY_LOCAL_MACHINE,&lt;br /&gt;
    HKEY_USERS,&lt;br /&gt;
    HKEY_CURRENT_CONFIG&lt;br /&gt;
}&lt;br /&gt;
public class RegKeyAttribute : Attribute {&lt;br /&gt;
    public RegKeyAttribute(RegHives Hive, String ValueName) {&lt;br /&gt;
        this.Hive = Hive;&lt;br /&gt;
        this.ValueName = ValueName;&lt;br /&gt;
    }&lt;br /&gt;
    protected RegHives hive;&lt;br /&gt;
    public RegHives Hive {&lt;br /&gt;
        get { return hive; }&lt;br /&gt;
        set { hive = value; }&lt;br /&gt;
    }&lt;br /&gt;
    protected String valueName;&lt;br /&gt;
    public String ValueName {&lt;br /&gt;
        get { return valueName; }&lt;br /&gt;
        set { valueName = value; }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class SomeClass {&lt;br /&gt;
    [RegKey(RegHives.HKEY_CURRENT_USER, &amp;quot;Foo&amp;quot;)]&lt;br /&gt;
    public int Foo;&lt;br /&gt;
    public int Bar;&lt;br /&gt;
}&lt;br /&gt;
class Test {&lt;br /&gt;
    [STAThread]&lt;br /&gt;
    static void Main(string[] args) {&lt;br /&gt;
        Type type = Type.GetType(&amp;quot;FieldAttribs.SomeClass&amp;quot;);&lt;br /&gt;
        foreach (FieldInfo field in type.GetFields()) {&lt;br /&gt;
            foreach (Attribute attr in&lt;br /&gt;
                field.GetCustomAttributes(true)) {&lt;br /&gt;
                RegKeyAttribute rka =&lt;br /&gt;
                    attr as RegKeyAttribute;&lt;br /&gt;
                if (null != rka) {&lt;br /&gt;
                    Console.WriteLine(&amp;quot;{0} will be saved in {1}\\\\{2}&amp;quot;, field.Name, rka.Hive, rka.ValueName);&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Static class variable==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Learning C# &lt;br /&gt;
by Jesse Liberty&lt;br /&gt;
Publisher: O&amp;quot;Reilly &lt;br /&gt;
ISBN: 0596003765&lt;br /&gt;
*/&lt;br /&gt;
 using System;&lt;br /&gt;
 namespace Test_Console_App_3&lt;br /&gt;
 {&lt;br /&gt;
     // declare a Cat class&lt;br /&gt;
     // stripped down&lt;br /&gt;
     class Cat&lt;br /&gt;
     {&lt;br /&gt;
         // a private static member to keep&lt;br /&gt;
         // track of how many Cat objects have&lt;br /&gt;
         // been created&lt;br /&gt;
         private static int instances = 0;&lt;br /&gt;
         private int weight;&lt;br /&gt;
         private String name;&lt;br /&gt;
         // cat constructor&lt;br /&gt;
         // increments the count of Cats&lt;br /&gt;
         public Cat(String name, int weight)&lt;br /&gt;
         {&lt;br /&gt;
             instances++;&lt;br /&gt;
             this.name = name;&lt;br /&gt;
             this.weight = weight;&lt;br /&gt;
         }&lt;br /&gt;
         // Static method to retrieve&lt;br /&gt;
         // the current number of Cats&lt;br /&gt;
         public static void HowManyCats()&lt;br /&gt;
         {&lt;br /&gt;
             Console.WriteLine(&amp;quot;{0} cats adopted&amp;quot;,&lt;br /&gt;
                 instances);&lt;br /&gt;
         }&lt;br /&gt;
         public void TellWeight()&lt;br /&gt;
         {&lt;br /&gt;
             Console.WriteLine(&amp;quot;{0} is {1} pounds&amp;quot;,&lt;br /&gt;
                 name, weight);&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
    public class StaticInClassTester&lt;br /&gt;
    {&lt;br /&gt;
       public void Run()&lt;br /&gt;
       {&lt;br /&gt;
           Cat.HowManyCats();&lt;br /&gt;
           Cat frisky = new Cat(&amp;quot;Frisky&amp;quot;, 5);&lt;br /&gt;
           frisky.TellWeight();&lt;br /&gt;
           Cat.HowManyCats();&lt;br /&gt;
           Cat whiskers = new Cat(&amp;quot;Whisky&amp;quot;, 7);&lt;br /&gt;
           whiskers.TellWeight();&lt;br /&gt;
           Cat.HowManyCats();&lt;br /&gt;
       }&lt;br /&gt;
       static void Main()&lt;br /&gt;
       {&lt;br /&gt;
          StaticInClassTester t = new StaticInClassTester();&lt;br /&gt;
          t.Run();&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==The super-string class.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
&lt;br /&gt;
public class MyString {&lt;br /&gt;
    private string fString;&lt;br /&gt;
    public MyString() {&lt;br /&gt;
        fString = &amp;quot;&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
    public MyString(string inStr) {&lt;br /&gt;
        fString = inStr;&lt;br /&gt;
    }&lt;br /&gt;
    public string ToStr() {&lt;br /&gt;
        return fString;&lt;br /&gt;
    }&lt;br /&gt;
    public string Right(int nChars) {&lt;br /&gt;
        if (nChars &amp;gt; fString.Length)&lt;br /&gt;
            return fString;&lt;br /&gt;
        string s = &amp;quot;&amp;quot;;&lt;br /&gt;
        for (int i = fString.Length - nChars; i &amp;lt; fString.Length; ++i)&lt;br /&gt;
            s += fString[i];&lt;br /&gt;
        return s;&lt;br /&gt;
    }&lt;br /&gt;
    public string Left(int nChars) {&lt;br /&gt;
        if (nChars &amp;gt; fString.Length)&lt;br /&gt;
            return fString;&lt;br /&gt;
        string s = &amp;quot;&amp;quot;;&lt;br /&gt;
        for (int i = 0; i &amp;lt; nChars; ++i)&lt;br /&gt;
            s += fString[i];&lt;br /&gt;
        return s;&lt;br /&gt;
    }&lt;br /&gt;
    public string Mid(int nStart, int nEnd) {&lt;br /&gt;
        if (nStart &amp;lt; 0 || nEnd &amp;gt; fString.Length)&lt;br /&gt;
            return fString;&lt;br /&gt;
        if (nStart &amp;gt; nEnd)&lt;br /&gt;
            return &amp;quot;&amp;quot;;&lt;br /&gt;
        string s = &amp;quot;&amp;quot;;&lt;br /&gt;
        for (int i = nStart; i &amp;lt; nEnd; ++i)&lt;br /&gt;
            s += fString[i];&lt;br /&gt;
        return s;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Class1 {&lt;br /&gt;
    static void Main(string[] args) {&lt;br /&gt;
        MyString s = new MyString(&amp;quot;Hello world&amp;quot;);&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;s = {0}&amp;quot;, s.ToStr());&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;Right 3 = [{0}]&amp;quot;, s.Right(3));&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;Left 6 = [{0}]&amp;quot;, s.Left(6));&lt;br /&gt;
        System.Console.WriteLine(&amp;quot;Mid 2,4 = [{0}]&amp;quot;, s.Mid(2, 4));&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>