I have this example to tell you what I'm looking for:
private void myMethod(string a = "", string b = "", string c = "")
{
// do things
}
I want to find a way where I can call that method like this:
MyParameterObject parameters = new MyParameterObject();
// b is the name of parameter
parameters.AddParameter("b", "b_value");
parameters.AddParameter("c", "c_value");
myMethod(parameters);
If all the parameter values required in the method are of same type(let it be string
) then you can pass the parameter as a Dictionary
like the following:
private void myMethod(Dictionary<string,string> paramDictionary)
{
// do things
}
So that you can call the method like this:
Dictionary<string,string> paramDictionary = new Dictionary<string,string>();
paramDictionary.Add("b", "b_value");
paramDictionary.Add("c", "c_value");
myMethod(paramDictionary);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With