C# ClassesLesson 25Free preview
C# Classes/Objects
This lesson is part of C# · All levels
Summary
A class is a definition that contains a field as data and a method as behavior, whereas an object is an instance created with the keyword new. Each object has its own copy of the field so that the data does not interfere with each other. From one class, you can make many objects under different conditions.
Key points
- Class is defined by the keyword class and name, then filled in the fields and method.
- Objects are created with new followed by the name class and curve, resulting in reference to the instance.
- The method called through the object works on the data belonging to the instance.
- Field instances are per object, as opposed to shared static members.
- It's best to write a class in a file so that the project structure is neat.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.