C#构造函数怎么初始化
1、给你写个简单的构造函数
class B
{
private String a;
private String x;
public B(String a,String x)
{
this.a = a ;
this.x = x ;
}
}
2、class A
{
B b = new B("hello","world") ;
}
你要明白定义构造函数的意义,这样构造函数得意义就是给类属性定义了。
阅读量:190
阅读量:165
阅读量:94
阅读量:138
阅读量:55
1、给你写个简单的构造函数
class B
{
private String a;
private String x;
public B(String a,String x)
{
this.a = a ;
this.x = x ;
}
}
2、class A
{
B b = new B("hello","world") ;
}
你要明白定义构造函数的意义,这样构造函数得意义就是给类属性定义了。