␡
- Creating Classes
- Creating Objects
- Using Access Modifiers
- Creating Fields and Using Initializers
- Creating Methods
- Creating Properties
- Read-only Properties
- Creating Constructors
- Creating Structs
- Creating Static Members
- Creating Static Fields
- Creating Static Properties
- Creating Destructors and Handling Garbage Collection
- Overloading Methods
- Overloading Operators
- Creating Namespaces
- In Brief
This chapter is from the book
Read-only Properties
You can also create read-only properties if you omit the set accessor method. For example, to make the Name property a read-only property, you use this code:
class Customer { private string name; public string Name { get { return name; } } }