I am working on a project in which I need to define any number of possible parameters when creating an object.
public class base
{
//Variable Declarations here...
public base(){ //Handle Arguments here... }
}
public class new1 : base
{
//Action Logic here...
}
My main issue comes from the declarations of “new1” (sorry for the poor naming conventions.) If the user wants to create an object that passes no further parameters, then the declaration works perfectly. However, If the user wants to create an object that does pass a parameter, I need to handle this with a new declaration.
public class new1<T1> : base
{
//New Action Logic here (handles T1)...
}
I understand one solution to this is simply limiting the user’s ability to create an object with ‘n’ number of parameters, and writing out new definitions of new with <T1> * n
parameters each, like:
public class new1<T1> : base { }
public class new1<T1,T2> : base { }
public class new1<T1,T2,T3> : base { } etc...
however, the possible inputs the user would have could exceed 10-11 entries, which would not only be a pain to manage in 10-11 different declarations but would also serve a messy solution.
I tried creating a class with an empty list of parameters. I expected to be able to create an object in which I could pass any number of parameters I needed.
public class new1<new T[]> { };
private static new1<string, string, int> test; //parameters are just an example
Any help would be appreciated, I am still learning. Thank you!
18