要定義一個靜態的屬性,需要在屬性定義前加上關鍵字"static"。例如:
public static int MyStaticProperty { get; set; }
這樣就定義了一個靜態的整型屬性MyStaticProperty。靜態屬性只能通過類名來訪問,而不是通過類的實例來訪問。