Differance between Const and Readonly

Const 1) Value evaluated at compile time 2) can't be static. 3) Initialize at declaration only. e.g. const int a = 100 Readonly 1) Value evaluated at runtime. 2) Can be static. 3) can initialize at declaration or in constructor. e.g. public readonly int doc = 5; public program() { doc = 5; }

Comments

  1. I have never implemented Const or Readonly. What is their extra ordinary purpose?

    ReplyDelete

Post a Comment

Popular posts from this blog

How to get motherboard serial number, Processor ID, VolumeSerialNumber using C#?

Fiserv Interview Questions.

AngularJs - Simple Example