📚 Lập trình C#
3 chương · 7 bài học
Tiến độ: 0 / 7 bài đã hoàn thành (0%)
Đang xem thử chương 1.
Đăng ký để làm quiz, theo dõi tiến độ và xem toàn bộ khoá học.
Xem khoá học
Classes and Objects
You learned from the previous chapter that C# is an object-oriented programming language.
Everything in C# is associated with classes and objects, along with its attributes and methods. For example: in real life, a car is an object. The car has attributes, such as weight and color, and methods, such as drive and brake.
A Class is like an object constructor, or a "blueprint" for creating objects.
When a variable is declared directly in a class, it is often referred to as a field (or attribute).
It is not required, but it is a good practice to start with an uppercase first letter when naming classes. Also, it is common that the name of the C# file and the class matches, as it makes our code organized. However it is not required (like in Java).