我有需要的ApiController類型參數爲這樣的方法:創建和傳遞一個類型參數
private List<MethodInfo> GetMethods<T>()
{
...
}
我想創建一個類型使用通過這種方法如下:
Type controller = Assembly.GetCallingAssembly().GetTypes().Where(
type => type.Name.Contains(schema) && type.IsSubclassOf(typeof(ApiController))).First();
var collection = GetMethods<controller>();
好吧,「找不到類型或命名空間控制器...」 讓我發瘋!
我敢肯定,有一件容易的事,我在這裏沒有看到,但我無法弄清楚。
我認爲你在找什麼:http://msdn.microsoft.com/en-us/library/system.object.gettype.aspx但這種方法似乎有點讓我困惑。 –