Difference between const and readonly in C#.NET

What is the difference between const and readonly in C#.NET?

ConstReadonly
It can be initialized const variables while declaration.It can be initialized only while declaration or in the constructor.
You cannot reassign a const variable.Once you initialize a field, you cannot reassign it.
Static modifier is not allowed.Static modifier is allowed for readonly fields.
It cannot be modified. It needs to be instantiated only at the compile time.It can be modified by the class.
Advantages of CLR procedure over T-SQL procedure - C#.NET
Advantages of CLR procedure over T-SQL procedure - The use of the CLR procedure makes it possible to do the complex database operations...
How does C# Generics and C++ Templates compare? - C#.NET
How does C# Generics and C++ Templates compare? - C# generics and templates in C++ are more or less similar syntactically...
What is an Object Pool in .NET? - C#.NET
What is an Object Pool in .NET? - An object pool is a container of objects that holds a list of other objects that are ready to be used...
Post your comment