I need to pass more than 10 parameters from one method to another all are of a different type.
If I pass them as parameters it's not looking nice.
I need to pass more than 10 parameters from one method to another all are of a different type.
If I pass them as parameters it's not looking nice.
Create a class like the below:
public class ParamObject
{
public string Blah1 { get; set; }
public DateTime Blah2 { get; set; }
}
And instantiate it and use it in your methods.
public void DoStuff (ParamObject uglyRecord)
{
//do stuff...
}
public void CallStuff()
{
ParamObject uglyRecord = new ParamObject();
uglyRecord.Blah1 = "things";
uglyRecord.Blah2 = DateTime.Now();
DoStuff(uglyRecord);
}
However, a method that accepts lots of parameters or complex objects is probably a sign that the method is doing too much and should be refactored into several smaller and simpler methods.