}
struct StructB
{
public StructB(int a)
{
Console.WriteLine(a);
}
public void output()
{
Console.WriteLine("success");
}
}
class Program
{
static void Main(string[] args)
{
ClassA A = new ClassA();
A.output();
//ClassB B = new ClassB();//错误,ClassB没有0个参数的构造函数
//B.output();
ClassB B = new ClassB(5);
B.output();
StructA SA = new StructA(); //调用结构体默认的构造函数
SA.output();
StructB SB = new StructB();//同类不一样,这种实例化的方式也是对的。
SB.output();
StructB SC = new StructB(5);//调用结构体带参的构造函数
SC.output();