c#中,struct和class的区别 1、struct不允许显示声明其无参数构造函数,这不同于class2、struct不允许声明时,初始化其数据成员值3、struct作为参数传递时,可考虑使用ref,以优化性能:因为是值类型(但要注意其值的改变)4、struct无继承,但其本身继承自System.ValueType ----> System.Object5、struct可看作是缩小的class,适宜小数据成员时使用6、理解如下代码: class Class1 { [STAThread] static void Main(string[] args) { Dimensions point = new Dimensions(); Console.WriteLine(point); Dimensions point1; point1.length = 100; point1.width = 200; Console.WriteLine(point1); Console.ReadLine(); } } public struct Dimensions { public double length; public double width; public override string ToString() { return this.length + " : " + this.width; } }