ホームページ  >  記事  >  バックエンド開発  >  C# の System.Reflection.Module とは何ですか?

C# の System.Reflection.Module とは何ですか?

PHPz
PHPz転載
2023-09-12 21:33:03807ブラウズ

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

#System.Reflection 名前空間には、アプリケーションに関する情報を取得し、型、値、オブジェクトをアプリケーションに動的に追加できるクラスが含まれています。

これには、Module クラスの新しいインスタンスを初期化するために使用されるモジュール コンストラクターがあります。モジュールは、1 つ以上のクラスとインターフェイスを備えた移植可能な実行可能ファイルです。

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 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事はtutorialspoint.comで複製されています。侵害がある場合は、admin@php.cn までご連絡ください。