Constant
const field can never be modified and must be initialized where it is declared
class Company
{
public const string CompanyName = "RK Inc";
}
Static Readonly
class Company
{
public static readonly string CompanyName = "RK Inc";
staticCompany()
{
CompanyName = "My Company";
}
}
Assigning the value to a readonly field outside the class will throw the following error:
Company.CompanyName = "My Company";
A static readonly field cannot be assigned to (except in a static constructor or a variable initializer)