Const vs Static vs Readonly in C#

Understand the differences between const, static, and readonly in C# with our comprehensive article guide
Const vs Static vs Readonly


Hi readers

Hope you all have a good time! You must have found some valuable information from my previous articles about c# application, Dot net core articles and interview question and answers. Now, we’ll see the difference between Static vs Const vs Readonly in C# application.

Const fields

Constant fields are the specific fields which we will be unable to alter again. At the particular step of declaration, you need to just assign the required value to it once.

For example;

const int b = 8;

Static modifier

If the static modifier is implemented to a particular class

 then you will be unable to initiate the class through the new keyword. You are allowed to utilize the static keyword on approaches, properties, constructors, classes,  etc.

For example:

static int a = 12;

Readonly field

A Readonly field gets initialized at the moment of declaration or you can set it within the constructor to make your work easier.

Go through the example to know how Readonly field gets initialized within the given constructor.

For example:


In sum, the reader must have got appropriate idea about use of Static vs Const vs Readonly in C# application. Working with C# DotNet application will be smoother than before.


Anjan kant

Outstanding journey in Microsoft Technologies (ASP.Net, C#, SQL Programming, WPF, Silverlight, WCF etc.), client side technologies AngularJS, KnockoutJS, Javascript, Ajax Calls, Json and Hybrid apps etc. I love to devote free time in writing, blogging, social networking and adventurous life

Post A Comment: