2011-10-16 1 views
0

예제 클래스의 mymethod 메서드에서 methodInfo가 있습니다.C#으로 메서드 정보 .IsDefined()를 true로 설정

이 어떻게 속성을 만들 수 있습니다

internal class Example 
{ 
    public static void mymethod(string str1, ref string str2, out string str3) 
    { 
     .... 


MethodInfo mm = typeof(Example).GetMethod("mymethod"); 
(예를 들어, ABCAttribute) mm의

mm.IsDefined(typeof(ABCAttribute), true) 

true가 될 정도로?

답변

3

속성을 정의해야합니다.

[AttributeUsage(AttributeTargets.Method)] 
public class ABCAttribute : Attribute 
{ 
} 

그런 다음 방법에 적용하십시오.

internal class Example 
{ 
    [ABC] 
    public static void mymethod(string str1, ref string str2, out string str3) 
    { 
    } 
}