Creating types

When we create a variable in C#, it provides us with plenty of options to choose the appropriate type of the variable. For example, we can choose the following:

  • We can choose an enum type if we would like the variable to acquire a defined set of variables. For example, if we define Day as an enum type, it can acquire the values Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday
  • Similarly, if we choose an int type, we tell common language runtime (CLR) that it cannot have decimal digits.

Hence, while defining types for any variables, we have to analyze the usage of the variable logically and then declare its type in C#. In the next section, we will just do a brief revision of the different types that we covered in the Data types in C# section in Chapter 2Understanding Classes, Structures, and Interfaces.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.123.155