MemberInfo.Module プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > MemberInfo.Module プロパティの意味・解説 

MemberInfo.Module プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

現在の MemberInfo によって表されるメンバ宣言する型が定義されているモジュール取得します

名前空間: System.Reflection
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

解説解説

このプロパティは、利便性向上のために用意されています。これは、DeclaringType プロパティ使用してメンバ宣言されている型を取得し取得した Type オブジェクトModule プロパティ呼び出すことと同じです。

使用例使用例

次のコード例は、Object継承するクラス宣言し、Object.ToString をオーバーライドしています。この例では、クラスToString メソッド、および継承された GetHashCode メソッドの MethodInfo オブジェクト取得し2 つメソッド宣言されているモジュールの名前を表示します

Imports System
Imports System.Reflection

Public Class Test
    Public Overrides Function
 ToString() As String
        Return "An instance of class Test!"
    End Function
End Class

Public Class Example
    Public Shared Sub Main()
        Dim t As New Test()
        Dim mi As MethodInfo = t.GetType().GetMethod("ToString")
        Console.WriteLine(mi.Name & " is defined in "
 & mi.Module.Name)

        mi = t.GetType().GetMethod("GetHashCode")
        Console.WriteLine(mi.Name & " is defined in "
 & mi.Module.Name)
    End Sub
End Class

' This example produces code similar to the following:
'
'ToString is defined in source.exe
'GetHashCode is defined in mscorlib.dll
using System;
using System.Reflection;

public class Test
{
    public override string ToString()
    {
        return "An instance of class Test!";
    }
}

public class Example
{
    public static void Main()
    {
        Test t = new Test();
        MethodInfo mi = t.GetType().GetMethod("ToString");
        Console.WriteLine("{0} is defined in {1}", mi.Name,
 mi.Module.Name);

        mi = t.GetType().GetMethod("GetHashCode");
        Console.WriteLine("{0} is defined in {1}", mi.Name,
 mi.Module.Name);
    }
}

/* This example produces code similar to the following:

  ToString is defined in source.exe
  GetHashCode is defined in mscorlib.dll
 */
using namespace System;
using namespace System::Reflection;

public ref class Test
{
public:
    virtual String^ ToString() override
    {
        return "An instance of class Test!";
    }
};

int main()
{
    Test^ target = gcnew Test();
    MethodInfo^ toStringInfo = target->GetType()->GetMethod("ToString");
    Console::WriteLine("{0} is defined in {1}", toStringInfo->Name
,
        toStringInfo->Module->Name);

    MethodInfo^ getHashCodeInfo = target->GetType()->GetMethod("GetHashCode");
    Console::WriteLine("{0} is defined in {1}", getHashCodeInfo->Name
,
        getHashCodeInfo->Module->Name);
}

/*
* This example produces the following console output:
*
* ToString is defined in source.exe
* GetHashCode is defined in mscorlib.dll
*/
import System.*;
import System.Reflection.*;

public class Test
{
    public String ToString()
    {
        return "An instance of class Test!";
    } //ToString
} //Test

public class Example
{
    public static void main(String[]
 args)
    {
        Test t = new Test();
        MethodInfo mi = t.GetType().GetMethod("ToString");
        Console.WriteLine("{0} is defined in {1}", mi.get_Name(),
 
            mi.get_Module().get_Name());

        mi = t.GetType().GetMethod("GetHashCode");
        Console.WriteLine("{0} is defined in {1}", mi.get_Name(),
 
            mi.get_Module().get_Name());
    } //main
} //Example

/* This example produces code similar to the following:

  ToString is defined in source.exe
  GetHashCode is defined in mscorlib.dll
 */
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

MemberInfo.Module プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



MemberInfo.Module プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS