"Brett Romero" <(E-Mail Removed)> wrote:
> Is there a way to get a generic type and use it to cast an "object"?
> For example:
>
> SomeClass<T>{}
>
> Used as:
> SomeClass<MyClass> sc = new SomeClass<MyClass>();
>
> I'd like to get MyClass as a type out of sc and do this:
>
> (sc.GenericType)SomeObject;
>
> or what ever that syntax will look like. Any suggestions?
Sure - create a generic method, and cast inside that:
void Foo<T>(SomeClass<T> sc)
{
(T) someObject
}
-- Barry
--
http://barrkel.blogspot.com/