国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

C# ?? ???

Oct 13, 2016 pm 04:31 PM

??? ????? ??? ????? ???? ?? ??? ?? ??? ???? ???? ????. ??? ???? get ???, set ??? ?? ? ?? ??? ? ????. ??? ?? ?? ? ??? ?????.

get {}
set {}

get ???:
get ??? ??? ??? ??? ?????. ?? ??? ?? ???? ???. get ???? ???? ?? ?? ?? ?? ?? ????.

??? ??? ?? ??? ?? ???? get ??????.

private string name;  // the name field
 
public string Name  // the Name 
 
property
{    
   get
   {       
       return name;
   }
}

??? ???? ??? ???? ?? ? ??? ?? ?? get ???? ?????. ??? ??.

?:

Employee e1 = new Employee();
 ...
 Console.Write(e1.Name); // The get accessor is invoked here

get ???? return ?? throw ??? ????? ?? ??? ??? ?? ???? ??? ? ????.



set ???:
set ???? void? ???? ???? ?????. value?? ??? ????? ????, ? ????? ??? ??? ?????.

?? ???? Set ???? Name ??? ?????.

public string Name
{  
   get
   {  
        return name;
   }  
     
   set
   {
       name = value;
   }
}

??? ?? ???? ???? set ???? ?????.

?:

e1.Name = "Joe"; // The set accessor is invoked here

set ????? ?? ?? ??? ??? ???? ??(?)? ???? ?? ?????.


??:

??? ??? ???? ?? ??? ?? ?????.
get ??? ??? ?????. ?? ?? ????? ???. ?? ?? ???? ?? ??? ? ????.
set ???? ?? ??? ?? ?? ????? ???. ?? ?? ??? ?? ??? ???? ??? ? ????.
get ? set ???? ?? ?? ??? ??/?? ?????.
?? ???? get ? set ???? ?? ?? ?? ???? ????? ???.
??? ??? ???? ?? get ???? ???? ?? ?? ?? ????? ??????.


???? ???? ???? ?? ?? ?? ?????.

 using System; 
 namespace AccessorEG
 {     
     public class Student
     {         
         // 私有字段 private field
         private int _age; 
          
         // 公開(kāi)的屬性 public property
         public int Age
         {             
            get { return _age; }             
            set { _age = value; }
         }
     } 
      
     class Program
     {         
         static void Main(string[] args)
         {
             Student stu = new Student();
             stu.Age = 10;                           // 使用了修改
             Console.WriteLine(stu.Age.ToString()); //使用了讀取 輸出 10                  
             Console.ReadKey();                    
         }
     }
 }

???? ??? ???? ????? ?? ???? ????. ?????? ?? ?? ???? ?? ?? ?? ?? ??? ???? ?? ?????, ?? ??? ?? ???? ?? ?? ?? ??? ??? ? ????.

?? ?? ??? ???? ?? ? ???? ?? ??? ?? ?? ? ???? ?? ???? ??? ? ????. ?? ?? ?? ???? ?? ???? ?? ? ?? ?????, ? get? ??? ? ??? ???? ?????? ???? ? ?? set ???? ???? ????.

 using System; 
 namespace AccessorEG
 {     
     public class Student
     {         
         // 私有字段 private field
         private readonly int _age = 10; 
          
         // 公開(kāi)的屬性 public property
         public int Age
         {   
               get { return _age; }
         }
     } 
      
     class Program
     {        
         static void Main(string[] args)
         {
             Student stu = new Student();
             Console.WriteLine(stu.Age.ToString());  // 使用了讀取   輸出 10                
             Console.ReadKey();                              
         }
     }
 }

? ???? ???? ??? ?? ??? ???? ???, public ??? ???? ????? set ???? ??? ? ????. ??? ??? ???? ????. ??????? ?? ???? ?? ? ????.

?? ???? ?? ????? ???. ???? ???? ??? ????.

using System; 
 namespace AccessorEG
 {     
     public class Student
     {         
         #region 全訪(fǎng)問(wèn)權(quán)限         // 私有字段
         private int _age;        // 與_age對(duì)應(yīng)的公開(kāi)屬性,包含了set和get方法
          
         public int Age
         {             
             get { return _age; }             
             set { _age = value; }
         } 
         // 如果您安裝了.NET3.0,那么您可以使用自動(dòng)屬性,屆時(shí),上面的代碼即可以下面的代替
      // 在VS.NET下輸入 prop 連擊兩下Tab鍵,編譯器會(huì)自動(dòng)幫您生成自動(dòng)屬性
      // public int Age { get; set; }
         #endregion // 全訪(fǎng)問(wèn)權(quán)限
  
         #region 只讀屬性         
         private string _name; 
          
         public string Name
         {             
            get { return _name; }
         } 
         // 等同于
      // public string Name { private set; get; }
         #endregion
  
         #region 只寫(xiě)屬性         
         private bool _sex; 
          
         public bool Sex
         {          
             set { _sex = value; }
         }         
         // 等同于
      // public bool Sex { set; private get; }
         #endregion
  
     } 
      
     class Program
     {         
         static void Main(string[] args)
         {
             Student stu = new Student();
             stu.Age = 18;             
             // stu.Name = "Johness"; 異常,編譯錯(cuò)誤,因?yàn)樵搶傩灾蛔x
         // Console.WriteLine(stu.Sex.ToString()); 異常,編譯錯(cuò)誤,因?yàn)樵搶傩灾粚?xiě)
             Console.WriteLine(stu.Age.ToString());  // 使用了讀取                    Console.ReadKey();             // 輸出 18         
         }
     }
 }

? ?? ?? ?? ? ?? ??? ?? ???? ?????. ???? ???? ???? ?? ???? ?? ??? ?????. ?? ?? ??? ??? ?? ? ?? ??? ?? ??? ??? ??? ???? ??? ? ????. ??? ??? 3.0? ??? ??(?? ??) ?? .NET2.0? ??? ???? ??? ?? ???? ???? ?? ????. ). ?? ???? ???? ??? ???? ? ? ??? ?? ????:

using System; 
 namespace AccessorEG
 {     
     public class Student
     {         
         // 私有字段
         private int _age;  // 與_age對(duì)應(yīng)的公開(kāi)屬性,包含了set和get方法
          
         public int Age
         {             
             get { return _age; } // 利用訪(fǎng)問(wèn)器對(duì)輸入的年齡進(jìn)行驗(yàn)證
         // 如果輸入值小于0或者大于100
         // 可以賦為默認(rèn)值18或者不進(jìn)行操作
             set 
             {                 
                   if (value >= 0 && value <= 100)
                    _age = value;   // 如果數(shù)據(jù)無(wú)效不進(jìn)行操作可以注釋以下內(nèi)容
                   else
                    _age = 18;
             }
         }
  
     } 
      
     class Program
     {         
         static void Main(string[] args)
         {
             Student stu = new Student();
             stu.Age = -2;   // 賦無(wú)效值                     
             Console.WriteLine(stu.Age.ToString()); 
             Console.ReadKey();    // 輸出 18         
         }
     }
 }


? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

??? ????
1597
29
PHP ????
1488
72
???