1.

Can You Declare A Class Or A Struct As Constant?

Answer»

No, User-defined TYPES including classes, structs, and arrays, cannot be const. Only the C# built-in types excluding System.Object may be declared as const. Use the READONLY modifier to CREATE a CLASS, struct, or array that is initialized one time at runtime (for example in a CONSTRUCTOR) and thereafter cannot be changed.

No, User-defined types including classes, structs, and arrays, cannot be const. Only the C# built-in types excluding System.Object may be declared as const. Use the readonly modifier to create a class, struct, or array that is initialized one time at runtime (for example in a constructor) and thereafter cannot be changed.



Discussion

No Comment Found