0

How property is different from fields in this case?

class MathClass { public const int ONE = 1; } static void Main(string[] args) { Console.Write(MathClass.ONE); } //Outputs 1 In one of the module, it was written ONE variable is a property and I cannot see any accessor here nor it is an auto-implemented property.

9th Oct 2020, 10:00 AM
Rohan Agarwal
Rohan Agarwal - avatar
1 Answer
+ 1
You dont need to use a static modifier if using the keyword const it's done for you by default, this is why you dont need to create an instance of this class to access its properties, once the const variable is assigned its value stays the same throughout the program.
9th Oct 2020, 10:15 AM
D_Stark
D_Stark - avatar