Answers for "private readonly variable c#"

C#
0

static readonly variable in c#

A Static Readonly type variable's value can be assigned at runtime or
  assigned at compile time and changed at runtime.
  But this variable's value can only be changed in the 
  static constructor. And cannot be changed further.
  It can change only once at runtime.
Posted by: Guest on June-11-2021
0

why to make private fields readonly in c#

f it's private and readonly , the benefit is that you can't inadvertently change it from another part of that class after it is initialized. The readonly modifier ensures the field can only be given a value during its initialization or in its class constructor.
Posted by: Guest on March-04-2021

C# Answers by Framework

Browse Popular Code Answers by Language