许明会的计算机技术主页

Language:C,C++,.NET Framework(C#)
Thinking:Design Pattern,Algorithm,WPF,Windows Internals
Database:SQLServer,Oracle,MySQL,PostSQL
IT:MCITP,Exchange,Lync,Virtualization,CCNP

导航

C#3.0技术探讨(2):自动属性 Auto Property

/*--===------------------------------------------===---
自动属性: Auto Property
常规的属性的get,set不必书写了。

--===------------------------------------------===---
*/
namespace xumh
{
    
class student
    {
        
public string Name{get;set;}
        
public int Age{get;set;}
        
public string Address{get;set;}
    };

    
class runMyApp
    {
        
static void Main()
        {
            student s
=new student();
            s.Name
="许明会";
            s.Age
=36;
            s.Address
="北大青鸟";
            System.Console.WriteLine(
"{0},年龄{1},地址{2}.",
                s.Name,s.Age,s.Address);
        }
    };
}

posted on 2007-12-03 17:20  许明会  阅读(366)  评论(0编辑  收藏  举报