次の方法で共有


Type.IsNestedPublic プロパティ

クラスが入れ子になっていて、パブリックとして宣言されているかどうかを示す値を取得します。

Public ReadOnly Property IsNestedPublic As Boolean
[C#]
public bool IsNestedPublic {get;}
[C++]
public: __property bool get_IsNestedPublic();
[JScript]
public function get IsNestedPublic() : Boolean;

プロパティ値

クラスが入れ子になっていて、パブリックとして宣言されている場合は true 。それ以外の場合は false

解説

VisibilityMask は、参照可能範囲属性を選択します。

使用例

[Visual Basic, C#, C++] 入れ子になったパブリック クラスを宣言し、その IsNestedPublic プロパティ値を表示する例を次に示します。

 
Imports System
Imports Microsoft.VisualBasic
' Enclose a class.
Public Class MyClassA
    ' Public nested class.
    Public Class MyClassB
    End Class 'MyClassB
    Public Shared Sub Main()
        ' Get the type of the nested class.
        Dim myTypeB As Type = GetType(MyClassA.MyClassB)
        ' Get the IsNestedPublic property of the nested class.
        Console.WriteLine(ControlChars.Cr + "The IsNestedPublic property value of the nested class is {0}.", myTypeB.IsNestedPublic.ToString())
    End Sub 'Main
End Class 'MyClassA

[C#] 
using System;
// Enclose a class.
public class MyClassA
{
    // Public nested class.
    public class MyClassB
    {
    }
    public static void Main(string[] args)
    {    
        // Get the type of the nested class.
        Type myTypeB = typeof(MyClassA.MyClassB);
        // Get the IsNestedPublic property of the nested class.
        Console.WriteLine("\nThe IsNestedPublic property value of the nested class is {0}.", myTypeB.IsNestedPublic.ToString());            
    }
}

[C++] 
#using <mscorlib.dll>

using namespace System;
// Enclose a class.
public __gc class MyClassA {
public:
   // Public nested class.
   __gc class MyClassB {
   };
};
int main() {
   // Get the type of the nested class.
   Type*  myTypeB = __typeof(MyClassA::MyClassB);
   // Get the IsNestedPublic property of the nested class.
   Console::WriteLine(S"\nThe IsNestedPublic property value of the nested class is {0}.", myTypeB->IsNestedPublic.ToString());            
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard

参照

Type クラス | Type メンバ | System 名前空間 | TypeAttributes