Sometimes, programmers find themselves in need of adding new functionality to already existing codes, in order to improve or complete them. If the said source code is available, the task is simple – they only need to add the required functionality and recompile.… Read more
Posts Tagged ‘static members’
Extension methods
Monday, May 4th, 2020Constants
Saturday, July 1st, 2017Just like constants in mathematics, C# defines special fields of classes called constants. Like their name hints, once declared and initialized, constants maintain their values, forbidding their further modification.
There are two types of constants:
- constants for which the value is set during the compilation (compile time constants)
- constants which have their value set during the execution (run-time constants)
Compile time constants are declared using the C# modifier const:
1 |
[<access_modifiers>] const <type> <name>; |
A secret not many C# programmers know is that compile time constants are static fields, even if they do not contain the static keyword, and the compiler forbids its usage in the declaration.… Read more
Static members
Thursday, May 18th, 2017As we saw in the previous recent lessons, the usual way of communicating with a class is to create instances (copies) of it, and then use the resulting objects. In fact, that is the strong advantage of the classes – the ability to create copies that can be used and can be modified individually.… Read more