构造方法也称构造函数,慢慢的我们会发现我们所写的每一个类都会用到构造函数,如果不编码则系统默认生成空的构造方法,如果我们定义的构造方法,那么默认的构造方法就会失效。
public News (){}
public News(string title,string content,string caid)
{
this .title =title ;
this .content =content ;
this .caId =caid;
}
以上是我们用到的构造方法也称构造函数。