In my class I have a few settings; let’s call them: setting1
, setting2
, setting3
. I want to pass an argument for setting1
and setting3
in the constructor without modifying setting2
or passing all 3 of them as an argument.
I have seen someone do this by using a dictionary and reading the key and then then changing the setting based on the value but I was wondering if there was a better way of doing this.
2
Class c1 = new(setting1: "AA", setting3: "CC");
Class c2 = new(setting2: "BB");
class Class(
string setting1 = "A",
string setting2 = "B",
string setting3 = "C")
{
public string setting1 = setting1;
public string setting2 = setting2;
public string setting3 = setting3;
}