Horje
readonly vs const c# Code Example
readonly vs const c#
readonly keyword is used to define a variable 
which can be assigned once after declaration 
either during declaration or in constructor. 
  
const keyword is used to define a constant to be used in the program.
c# const vs readonly
A const is a compile-time constant whereas readonly allows a value to be calculated at run-time and set in the constructor or field initializer. So, a 'const' is always constant but 'readonly' is read-only once it is assigned.

Eric Lippert of the C# team has more information on different types of immutability.




Csharp

Related
C# Cast double to float Code Example C# Cast double to float Code Example
c# hex to console color Code Example c# hex to console color Code Example
c# require administrator permissions Code Example c# require administrator permissions Code Example
require admin privileges c# Code Example require admin privileges c# Code Example
generate random name c# Code Example generate random name c# Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9