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);