What parts does a C# class usually contain?

Experience Level: Junior
Tags: C#

Answer

The class contains members. There are many different kinds of members but the three most important kinds are propertiesmethods and constructors.

  • Properties allow you to read/write data values from/to an object that is created based on the class. Properties serve as a middleman between the external code and object underlying data values.
  • Methods contain code blocks that can be executed on a class or on an object that is created based on the class.
  • Constructors are special methods that are executed immediately after the object is created from class. A constuctor that is calles initializes the values of the object. A constructor is a method whose name is the same as the name of its class.

Comments

No Comments Yet.
Be the first to tell us what you think.
C# for beginners
C# for beginners

Are you learning C# ? Try our test we designed to help you progress faster.

Test yourself