C# ClassesLesson 26Free preview
C# Class Members
This lesson is part of C# · All levels
Summary
A class member consists of a field as a data, a method as a behavior, and a property as a data access gateway. This keyword refers to a running instance, useful to distinguish a field from a parameter of the same name. Static members live at the class level so they don't need objects to be called.
Key points
- Fields store object data, methods store behavior, and properties control data access.
- This refers to the current instance, often used in constructors such as this.nama = name.
- Static members are called by the class name and cannot access the instance members without objects.
- Public members are accessible from outside the class, while private members are only accessible from within the class itself.
- Combining fields and related methods makes classes more cohesive and easy to maintain.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.