Understanding Classes, Structures, and Interfaces

In Chapter 1, Learning the Basics of C#, we looked at an overview of the very basic components of a C# application. All classes in a C# application are composed of attributes and methods. Using namespaces and assemblies, we can bundle related classes together.

To maintain structure and to reduce complexity, it's essential that only the required classes/functionality are exposed outside the scope of a class. In a C# program, this is achieved via access modifiers. While defining the attributes present in a class, we also need to be clear about the different data types of variables available in C#.

Using a code implementation of struct and class, we will look at how data and reference type variables differ in implementation and behavior during program execution. We will also be looking at some good practices that we can follow to choose the right data type for our variables.

We will then look at interfaces and inheritance and how they are implemented in a C# application. Using examples, we will look at the different scenarios in which we should use each of them.

The following topics will be covered in this chapter:

  • Different types of access modifiers in C#
  • Different types of data types in C#
  • Understanding the difference between a class and a struct
  • Understanding inheritance
  • Understanding interfaces and how they are different from inheritance

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

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