set default value in class constructor C#
问题 I need a default value set and many different pages access and update..initially can I set the default value in the class constructor like this? What is the proper way to do this in C# .NET? public class ProfitVals { private static double _hiprofit; public static Double HiProfit { get { return _hiprofit; } set { _hiprofit = value; } } // assign default value HiProfit = 0.09; } 回答1: You can put it in the declaration: private static double _hiprofit = 0.09; Or if it's a more complicated