Computer >> 컴퓨터 >  >> 프로그램 작성 >> C#

C#의 System.Reflection.Module은 무엇입니까?


System.Reflection 네임스페이스에는 응용 프로그램에 대한 정보를 얻고 유형, 값 및 개체를 응용 프로그램에 동적으로 추가할 수 있는 클래스가 포함되어 있습니다.

여기에는 Module 클래스의 새 인스턴스를 초기화하는 모듈 생성자가 있습니다. 모듈은 하나 이상의 클래스와 인터페이스가 있는 이식 가능한 실행 파일입니다.

C#에서 System.Reflection의 예를 살펴보겠습니다 −

using System;
using System.Reflection;

[AttributeUsage(AttributeTargets.All)]
public class HelpAttribute : System.Attribute {
   public readonly string Url;

   public string Topic // Topic is a named parameter {
      get {
         return topic;
      }

      set {
         topic = value;
      }
   }

   public HelpAttribute(string url) // url is a positional parameter {
      this.Url = url;
   }

   private string topic;
}

[HelpAttribute("Information on the class MyClass")]
class MyClass {
}

namespace AttributeAppl {
   class Program {
      static void Main(string[] args) {
         System.Reflection.MemberInfo info = typeof(MyClass);
         object[] attributes = info.GetCustomAttributes(true);
         for (int i = 0; i < attributes.Length; i++) {
            System.Console.WriteLine(attributes[i]);
         }
         Console.ReadKey();
      }
   }
}