Declare set get property as private

Sourav.Kayal
Posted by Sourav.Kayal under C# category on | Points: 40 | Views : 905
namespace BlogProject
{
class StaticTest
{
public String Name { get; private set; }
}

class Program
{
static void Main(string[] args)
{
StaticTest t = new StaticTest();
t.Name = "Sourav"; // Cannot assign value
Console.ReadLine(); //Because set property is declare as private
}
}
}

Comments or Responses

Login to post response