Write modifiers — RexDac Academy

RexDac AcademyTechnical notes · Some prior knowledge helps
0%Published notes read · this device

Level 4 — Classes

Write modifiers

Original notes by SunDiaL · View English source

Fields can be altered a bit using the following keywords:

  • readonly -> can have its value set only in the constructor. Trying to change its value outside of a constructor will cause a compiler error
  • const -> replaced at compile time with their values
  • volatile -> indicates that a field might be modified by multiple threads that are executing at the same time

Never used volatile in my life so here's the official docs: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/volatile