可能重複:
default value for a static property如何在C#類的靜態默認屬性分配默認值?
我能夠一類的正常的默認屬性分配默認值。 但我不能爲一類像下面的靜態默認屬性分配默認值: -
public class AppInstance
{
[DefaultValue(25)]
public static int AppType { get; set; }
}
當我打電話AppInstance.AppType,它總是返回0,而不是25麼?我如何解決它而不使用私有變量聲明?
指定它在[靜態]構造函數。 – Servy 2012-04-25 14:08:25
http://stackoverflow.com/questions/2596344/default-value-for-a-static-property – LaGrandMere 2012-04-25 14:09:11
默認值是可視化組件的屬性,由Visual Studio設計 – 2012-04-25 14:09:12