C#学习小记1 没有main() 及我突发的想起来的,使用来验证在类内可以实例化本类的对象

//我想证明在编译一个程序时如果没有main(),那么是不会通过编译的比如:
using System;
public class Success{
int i;
i=3;

}
//结果上例是不行的!
//下面这个例子是我突发的想起来的,使用来验证在类内可以实例化本类的对象,
using System;
public class Student
{ private string name;
public string Name
    {
     get {return name;}
     set { name =value;}
    }
public Student (string s)
    {
     Name=s;
    }
static void Main()
{ Student a=new Student("me");
    Console.WriteLine(a.Name);
}
}
//实验成功!哈哈说明类内也能实例化本类的对象!


posted on 2008-08-06 13:22  yatasoft  阅读(278)  评论(0编辑  收藏  举报

导航