Answer: It is used to declare constants which cannot be modified. In C#, mostly we declare the const for
numeric types,
value types,
strings etc.
Only way to modify a constant field is to do that at
compile time only as
const keyword restricts the field from being modified in the
runtime.
Example,
const string Site = "DotNetFunda"; // Declaration of constant field
Site = "ITFunda"; // Compile time error
Asked In: Spotted While Learning |
Alert Moderator