J
Jon Slaughter
I have some code like
if (val.GetType().Name == typeof(List<>).Name)
{
}
which lets me determine if val is a generic list(I've already taken care of
the non-generic part but I'd rather be able to compare them like if (val is
List<>) but this obviously doesn't work. (and I can't code it for every
parameter)
But now I need to create a new type reference from val so I can use its
methods.
in the non-generic version I have
List l = new List() because I know its a list.
In the generic version I can't do this cause I don't know the generic
parameter at compile time. Something like
List<object> l = (List<object>)val;
doesn't even work which might be ok if it did.
The code I'm using is independent of the generic parameter so it doesn't
really matter what it is(casting them to objects isn't an issue for me as
long as the type is bound to it).
Any ideas?
Thanks,
Jon
if (val.GetType().Name == typeof(List<>).Name)
{
}
which lets me determine if val is a generic list(I've already taken care of
the non-generic part but I'd rather be able to compare them like if (val is
List<>) but this obviously doesn't work. (and I can't code it for every
parameter)
But now I need to create a new type reference from val so I can use its
methods.
in the non-generic version I have
List l = new List() because I know its a list.
In the generic version I can't do this cause I don't know the generic
parameter at compile time. Something like
List<object> l = (List<object>)val;
doesn't even work which might be ok if it did.
The code I'm using is independent of the generic parameter so it doesn't
really matter what it is(casting them to objects isn't an issue for me as
long as the type is bound to it).
Any ideas?
Thanks,
Jon