Have you failed a job interview?
Send us your job interview questions and get correct answers.
What parts does a C# class usually contain?
Experience Level: Junior
The class contains members. There are many different kinds of members but the three most important kinds are properties, methods 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.
Related C# job interview questions
What is a method in C# and how do you define one?C# Junior
What is a constructor in C# and why would you use it?C# Junior
What is a project in Visual Studio and what file extension does it have?C# Junior
What is a solution in Visual Studio and what file extension does it have?C# Junior
What is a difference between .cs file and class?C# Junior