2012-04-27 60 views

回答

3

循環遍歷每個類的每個方法,並檢查GetCustomAttributes(typeof(DllImportAttribute))是否返回任何內容。

3
assembly.GetTypes() 
     .SelectMany(t => t.GetMethods(flags)) 
     .Where(m => Attribute.GetCustomAttribute(m, typeof(DllImportAttribute)) != null); 
+0

您需要方法 – SLaks 2012-04-27 18:46:53

+0

@SLaks:絕對!更新。謝謝 – abatishchev 2012-04-28 06:11:09