[RESOLVED] [2.0] Passing a type as a parameter
I want to make a function like this:
Code:
private List<Type> GetSubClasses(Type type)
{
Type[] TypeList = System.Reflection.Emit.AssemblyBuilder.GetExecutingAssembly().GetTypes();
List<Type> Result = new List<Type>();
foreach(Type typ in TypeList)
{
if (typ.BaseType == type)
Result.Add(typ);
}
return Result;
}
This will (hopefully) list all subclasses of a given class. The trouble is i get a compiler error when i write code to call it:
'CEffect' is a 'type', which is not valid in the given context
(CEffect is a class)
I'm guessing i can do this since the function accepting a type did accept it, i'm just not sure how i pass in a type.
I know i could do it like this Type.GetType("Magic.CEffect",true), but i want to avoid that really as it looks pretty ugly and isn't as universal as i would like.
Any help would be great!
EDIT: doh, didn't see the 'typeof' keyword!!!
Re: [2.0] Passing a type as a parameter
Please mark your thread as resolved using the Thread Tools menu if it is indeed resolved.
Re: [RESOLVED] [2.0] Passing a type as a parameter