Type.DeclaringTypeとは? わかりやすく解説

Type.DeclaringType プロパティ

このメンバを宣言するクラスを取得します。

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

Public Overrides ReadOnly
 Property DeclaringType As Type
Dim instance As Type
Dim value As Type

value = instance.DeclaringType
public override Type DeclaringType { get; }
public:
virtual property Type^ DeclaringType {
    Type^ get () override;
}
/** @property */
public Type get_DeclaringType ()

プロパティ値
このメンバを宣言するクラスの Type オブジェクト。型が入れ子にされている場合、このプロパティは外側の型を返します。

解説解説
使用例使用例

派生クラスでメソッドの型宣言を表示するコード例を次に示します。

Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic

Public MustInherit Class
 dtype

    Public MustInherit Class
 MyClassA
        Public MustOverride Function
 m() As Integer
    End Class

    Public MustInherit Class
 MyClassB
        Inherits MyClassA
    End Class

    Public Shared Sub Main()
        Console.WriteLine("The declaring type of m is {0}.",
 _
           GetType(MyClassB).GetMethod("m").DeclaringType)
    End Sub
End Class
using System;
using System.Reflection;
 
public abstract class dtype 
{
    
    public abstract class MyClassA 
    {
        public abstract int m(); 
    }
    
    public abstract class MyClassB : MyClassA
 
    {
    }
  
    public static void Main(string[]
 args) 
    { 
        Console.WriteLine("The declaring type of m is {0}.",
            typeof(MyClassB).GetMethod("m").DeclaringType);
    }
}
using namespace System;
using namespace System::Reflection;

public ref class dtype abstract
{
public:
   ref class MyClassA abstract
   {
   public:
      virtual int m() = 0;
   };

   ref class MyClassB abstract: public MyClassA{};
};

int main()
{
   Console::WriteLine( "The declaring type of m is {0}.", dtype::MyClassB::typeid->GetMethod(
 "m" )->DeclaringType );
}
import System.*;
import System.Reflection.*;

abstract public class Dtype
{
    abstract public class MyClassA
    {
        public abstract int M();
    } //MyClassA
      
    abstract public class MyClassB extends
 MyClassA
    {
    } //MyClassB
   
    public static void main(String[]
 args)
    {
        Console.WriteLine("The declaring type of M is {0}.", 
        MyClassB.class.ToType().GetMethod("M").get_DeclaringType());
    } //main
} //Dtype
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

_Type.DeclaringType プロパティ

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

COM オブジェクトに、Type.DeclaringType プロパティへのバージョンに依存しないアクセスが用意されています。

このプロパティは、CLS に準拠していません。  

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

Dim instance As _Type
Dim value As Type

value = instance.DeclaringType
Type DeclaringType { get; }
property Type^ DeclaringType {
    Type^ get ();
}
/** @property */
Type get_DeclaringType ()
function get DeclaringType () : Type

プロパティ値
このメンバを宣言するクラスの Type オブジェクト。型が入れ子にされている場合、このプロパティは外側の型を返します。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「Type.DeclaringType」の関連用語

Type.DeclaringTypeのお隣キーワード
検索ランキング

   

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



Type.DeclaringTypeのページの著作権

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

©2026 GRAS Group, Inc.RSS