1、下面是一个结构的定义:
public struct Point { public int X { get; set; } public int Y { get; set; } }
public class Animal { public string Name { get; set; } public double Weight { get; private set; } private string _color; public string Color { get { return _color; } set { _color = value; } } public void MakeSound() { Console.WriteLine(Sound); } }
public struct Point { public int X { get; set; } public int Y { get; set; } public Point(int X, int Y) { this.X = X; this.Y = Y; } }
Point p = new Point(); Point P = new Point(10, 12);
快速入门C#编程之struct和class对比,布布扣,bubuko.com
原文地址:http://blog.csdn.net/bluecloudmatrix/article/details/34813243