used2could
asked on
List<myObject.GetType()> lstStuff Concept - Please Help
I am trying to do something like List<String> lstStuff without having to use the keyword "String". The objects that will go through this are dynamic and i can't reference it's type by name. I've tried things such as List<myObject.GetType()> or List<typeof(myObject)> but that give a compiler error. Are there any ways to pass the generic type without using the actual object's type name? Thanks. This is extremly urgant. i'm trying to implement a fix for a system that can only be brought down for a few hours.
Thanks.
Oh, as a side note the actual method i am trying this on isn't "List". I am using "List" as a popular example. It's really a custom method. Parse<T>(T objectToParse)
Thank you so much!
~B
Thanks.
Oh, as a side note the actual method i am trying this on isn't "List". I am using "List" as a popular example. It's really a custom method. Parse<T>(T objectToParse)
Thank you so much!
~B
Have you tried using Object?...
ASKER
Thanks Idle Mind,
I can't use Object because the actions applied to the passed in Type are specific to the Type being used.
I can't use Object because the actions applied to the passed in Type are specific to the Type being used.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
There are too many different types that could be passed in. I'm going to have to use objects and reflection. I didn't want to go that route but oh well. Just for the record, there is no way to use List<GetType()> for generics?
Thanks
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks guys!! i started re-writing it to accommodate objects and allow the method using generics to still access them via overloading to keep other things from breaking. Thanks for the clarifications!
ASKER
I'll be inspecting the member's details via reflection. That should do it. Thanks!