Set properties of a class only through constructor

c#, constructor, properties, set

Solution

Make the properties have readonly backing fields:

public class Thing
{
   private readonly string _value;

   public Thing(string value)
   {
      _value = value;
   }

   public string Value { get { return _value; } }
}

Problem

I am trying to make the properties of class which can only be set through the constructor of the same class.

Original source

Related problems