创建类
例如:
public class Student
{
public int Id{get;set;} //为类定义字段
public string StuName{get;set;}
//可以写一些方法
例:
public string Get()
{
//方法体
}
}
调用类
Student s1=new Student();
string str=s1.Get();//调用类的方法
声明一个类 类内包含字段和函数(所谓的方法)
class 类名{ 字段; 方法}
调用的时候先实例化 然后调用其中的方法来调用类,空间有限无法详细描述
对这个类添加引用就可以了,(在当前程序中using被调用类的命名空间.被调用类名)。
调用类New就行了。例如News ns = new News();这样