What is read only and static read only in C#?

Forums C#What is read only and static read only in C#?
Staff asked 2 years ago

Answers (1)

Add Answer
Umang Ramani Marked As Accepted
Staff answered 2 years ago
Static ReadOnly
Static classes, constructors, methods, variables, properties, events, and operators are possible. Static structs, indexers, enums, destructors, and finalizers are not permitted. Only class-level fields are read-only. Methods’ local variables cannot be read-only.
ClassName can be used to access static members. StaticMemberName, but not accessible via object. Object, but not ClassName, can be used to access read-only members. ReadOnlyVariableName.
The static members’ values can be changed by using ClassName. StaticMemberName. Readonly variable cannot be modified at run-time. It can only be initialized or changed in the constructor.

Subscribe

Select Categories