c# struct(结构体)注意事项

1、struct 不能定义默认构造函数、析构函数

2、struct 定义非默认构造函数需要对所有字段进行赋值

3、struct 不能派生也不能继承,但可以实现接口

4、struct 成员字段不能赋值初始化(class 可以)

5、struct 默认访问权限同 class 默认访问权限都是private

猜你喜欢

转载自www.cnblogs.com/laogaoyang/p/12593431.html