C# OOPChapter 3 · C# Object Oriented Programming
Objects and classes
C# is an object-oriented language. A class is a blueprint, and an object is an instance of that class. Use the new keyword to instantiate an object.
Worked example
class Cloud {
public string Shape;
public int Altitude;
public Cloud(string shape, int altitude) {
Shape = shape;
Altitude = altitude;
}
}
// In Main:
Cloud myCloud = new Cloud("cumulus", 3000);How it reads
- public string Shape declares a public field
- public Cloud(...) is a constructor used to initialize the object
- new Cloud(...) creates a new instance on the heap

Cloud tip: Fields are marked with access modifiers like public or private. private fields can only be accessed within the class itself.


