If we can only read the value of property and not assign the value to property that is called Readonly property. Readonly property can be implemented using the only get accessor and do not implement set accessor.
C# Source Code:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApp
{
class Program
{
public static int my_value
{
get
{
return 12;
}
}
static void Main(string[] args)
{
Console.WriteLine(my_value);
//Error
//my_value = 13;
Console.ReadLine();
}
}
}
0 comments:
Post a Comment