In this chapter:
In this chapter, I’ll show you how to add data members to a type. Specifically, we’ll look at constants and fields.
A constant is a symbol that has a
never-changing value. When defining a constant symbol, its value must be
determinable at compile time. The compiler then saves the constant’s
value in the assembly’s metadata. This means that you can define a constant only
for types that your compiler considers primitive types. In C#, the
following types are primitives and can be used to define constants:
String. However, C# also allows you to define a constant variable of a ...