Let's say I have a class like this:
public class SampleClass
{
const string UnChangableUserName { get; private set; }
string Password { get; private set; }
public SampleClass(string UnChangableUserName, string Password)
{
this.Password = Password;
this.UnChangableUserName = UnChangableUserName;
}
}
I want the constructor to assign a value to the const, and not for the value to be set when the const is defined. How can I do it?
I'm aware I can simply not use set but using const is more resource efficent and more elegant as well as clearer to other devs to understand, I don't want a set so they will not add it.