>  기사  >  백엔드 개발  >  C#의 System.Reflection.Module이란 무엇입니까?

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

PHPz
PHPz앞으로
2023-09-12 21:33:03807검색

C# 中的 System.Reflection.Module 是什么?

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

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

C#의 System.Reflection 예제를 살펴보겠습니다. -

Example

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();
      }
   }
}

위 내용은 C#의 System.Reflection.Module이란 무엇입니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
이 기사는 tutorialspoint.com에서 복제됩니다. 침해가 있는 경우 admin@php.cn으로 문의하시기 바랍니다. 삭제