I am trying to make the properties of class which can only be set through the constructor of the same class.
This page from Microsoft describes how to achieve setting a property only from the constructor.
You can make an immutable property in two ways. You can declare the set accessor.to be private. The property is only settable within the type, but it is immutable to consumers. You can instead declare only the get accessor, which makes the property immutable everywhere except in the type’s constructor.
In C# 6.0 included with Visual Studio 2015, there has been a change that allows setting of get only properties from the constructor. And only from the constructor.
The code could therefore be simplified to just a get only property:
public class Thing
{
public Thing(string value)
{
Value = value;
}
public string Value { get; }
}