### Introduction

In this post I'm going to explain about the Difference between Const, ReadOnly & Static in C#.

### Difference

A. Constants
1. Constants can be assigned values only at the time of declaration
2. Constant variables have to be accessed using "Classname.VariableName"
3. Constants are known at compile time
1. Read only variables can be assigned values either at runtime or at the time of instance initialization via constructor
2. Read only variables have to be accessed using the "InstanceName.VariableName"
3. Read only variables are known at run time.
C. Static
1. If the static keyword is applied to a class, all the members of the class must be static.
2. Static methods can only access static members of same class. Static properties are used to get or set the value of static fields of a class.
3. Static constructor can't be parameterized.
4. Access modifiers can not be applied on Static constructor, it is always a public default constructor which is used to initialize static fields of the class.

### Example

```using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

{
class Program
{
static void Main(string[] args)
{

Console.WriteLine(differentInstance.number);

//ConstantEx.number = 9;
// Const
Console.WriteLine(ConstantEx.number);

}
}

{
public readonly int number = 10;
{
number = 20;
}
{
number = 100;
}
}

class ConstantEx
{
public const int number = 3;
}

{
readonly static string number2;
readonly static string number3 = "Surajit";

{
number2 = number3;
number3 = "Surajit Ghosh";
Console.WriteLine("Readonly static " + number2);
}
}

public static class staticEX
{
public static int SS = 80;
public static int A = 90;

public static void Access()
{
int s = A;
}
}
}
```

### Conclusion

Guys hope I explain it peoperly.
{"ft_lang_label":"__label__en","ft_lang_prob":0.6263511,"math_prob":0.9731807,"size":2213,"snap":"2019-35-2019-39","text_gpt3_token_len":480,"char_repetition_ratio":0.17745586,"word_repetition_ratio":0.012383901,"special_character_ratio":0.23361953,"punctuation_ratio":0.17771883,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97363085,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-09-16T06:34:12Z\",\"WARC-Record-ID\":\"<urn:uuid:878bad75-eeb0-47d3-8d80-c9bc2f708961>\",\"Content-Length\":\"171135\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:d7b72f45-b736-4f63-bd45-4948f25624b9>\",\"WARC-Concurrent-To\":\"<urn:uuid:360891b0-12d4-4120-91af-d7cf57747c24>\",\"WARC-IP-Address\":\"172.217.7.211\",\"WARC-Target-URI\":\"http://www.coder007.com/2015/10/difference-between-const-readonly-static.html\",\"WARC-Payload-Digest\":\"sha1:76FMO5ZMARGWBBCGOEWP3H4R3VVPKJLQ\",\"WARC-Block-Digest\":\"sha1:M6FEYH2JIW7PTI2XFGQ33V22R7D5EWPC\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-39/CC-MAIN-2019-39_segments_1568514572491.38_warc_CC-MAIN-20190916060046-20190916082046-00138.warc.gz\"}"}