How to add a ReadOnly property in C#.NET

How to add a ReadOnly property in C#.NET?

Properties can be made read-only by having only a get accessor in the implementation.
public class X
{
   public X(int id)
   {
       x_id = id;
   }
   public int ID
   {
       get
       {
           return x_id;
       }
   }
}
How to prevent a class from being inherited in C#.NET
How to prevent a class from being inherited in C#.NET? - The sealed modifier is used to prevent derivation from a class...
What are generics in C#.NET?
What are generics in C#.NET? - Generic types to maximize code reuse, type safety, and performance....
Use of GetCommandLineArgs() method in C#.NET
What is the use of GetCommandLineArgs() method in C#.NET? - With GetCommandLineArgs() method, the command line arguments can be accessed...
Post your comment