public class MySingletonClass
{
private static MySingletonClass mySingletonClass;
private const decimal someDiscount = 3.00M;
public static MySingletonClass Instance
{
get
{
if (mySingletonClass == null)
mySingletonClass = new mySingletonClass();
return mySingletonClass;
}
}
....
public static decimal SomeDiscount
{
get { return this.someDiscount;}
}
...
}
我想公開someDiscount作爲一個屬性,所以我可以稍後在靜態實例屬性中使用它。我想你不能用一個常量來做到這一點?不能從單體或屬性中暴露常量