it's possible to make a class in C# where all fields and properties are const by default?
- Imaginary example *
public class foo : const /* or readonly */
{
public int baa = 3;
}
it's possible to make a class in C# where all fields and properties are const by default?
public class foo : const /* or readonly */
{
public int baa = 3;
}
No, it's not.
You can make a class static though which forces all members to be static.
Ex:
public static class Constants
{
public const int SomeId = 123;
public const string SomeName = "foo";
public static readonly DateTime myDateTime = new DateTime();
public string notConstant = "test"; //does not compile
}