public class YourAwesomeClass { private static string _firstName; public static string FirstName { get { return _firstName; } } public YourAwesomeClass(string firstName) { _firstName=firstName; } }
or if you use Dotnet 3.0 or higher, you can use the automatic property, Compiler will automatically create support fields for you.
public class YourAwesomeClass { public static string FirstName { get;private set; } public YourAwesomeClass(string firstName) { FirstName=firstName; } }
source share