.net - C# Variable with different amount of generic args based on some condition -
i'm not sure if title describing in best way i'll problem- have variable pabs
list of 4-tuples, 5-tuples, or 6-tuples based on condition...the problem don't know 1 i'm having trouble declaring type variable.
basically want this:
if (condition1) pabs = loaddata() // returns list of 4-tuples else if (condition2) pabs = loaddata() // overloaded version returning list of 5-tuples else pabs = loaddata() // overloaded version returning list of 6-tuples
is possible @ all?
what mean 'list of n-tuples'? should list of tuple of n elements' because .net define list list<t>
, many tuples tuple<t>, tuple<t1, t2>, tuple<t1, t2, t3>, ...
if want variable pabs list<tuple<t1,..., t4>>
or list<tuple<t1,..., t5>>
or list<tuple<t1,..., t6>>
. want pabs can take 3 different types. therefore can't give common type 3 different types unless object. later use bads must ask type , depending type is, doing something.
if(pabs list<tuple<t1,..., t4>>){...} else if(pabs list<tuple<t1,..., t5>>){...} else{...}
Comments
Post a Comment