Type.IsNestedPrivate 属性

获取一个值,通过该值指示 Type 是否是嵌套的并声明为私有。

**命名空间:**System
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
Public ReadOnly Property IsNestedPrivate As Boolean
用法
Dim instance As Type
Dim value As Boolean

value = instance.IsNestedPrivate
public bool IsNestedPrivate { get; }
public:
virtual property bool IsNestedPrivate {
    bool get () sealed;
}
/** @property */
public final boolean get_IsNestedPrivate ()
public final function get IsNestedPrivate () : boolean

属性值

如果 Type 是嵌套的并声明为私有的,则为 true;否则为 false

备注

如果当前 Type 表示某种泛型类型的类型参数,则此属性始终返回 false

TypeAttributes.VisibilityMask 选择可见性属性 (Attribute)。

示例

下面的示例将一个嵌套类声明为私有,并显示该嵌套类的 IsNestedPrivate 属性 (Property) 值。

Imports System
Imports Microsoft.VisualBasic
' Outer class.
Public Class MyClassA
    ' Private nested class.
    Private 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 IsNestedPrivate property of the nested class.
        Console.WriteLine(ControlChars.Cr + "The IsNestedPrivate property value of the nested class is {0}.", myTypeB.IsNestedPrivate.ToString())
    End Sub 'Main
End Class 'MyClassA
using System;
// Outer class.
public class MyClassA
{
    // Private nested class.
    private class MyClassB
    {
    }
    public static void Main(string[] args)
    {   
        // Get the type of the nested class.
        Type myTypeB = typeof(MyClassA.MyClassB);
        // Get the IsNestedPrivate property of the nested class.
        Console.WriteLine("\nThe IsNestedPrivate property value of the nested class is {0}.", myTypeB.IsNestedPrivate.ToString());  
    }
}
using namespace System;

// Outer class.
public ref class MyClassA
{
private:

   // Private nested class.
   ref class MyClassB{};


public:
   static void Test()
   {
      // Get the type of the nested class.
      Type^ myTypeB = MyClassA::MyClassB::typeid;
      
      // Get the IsNestedPrivate property of the nested class.
      Console::WriteLine( "\nThe IsNestedPrivate property value of the nested class is {0}.", myTypeB->IsNestedPrivate );
   }
};

int main()
{
   MyClassA::Test();
}
import System.*;

// Outer class.
public class MyClassA
{
    // Private nested class.
    private class MyClassB
    {
    } //MyClassB

    public static void main(String[] args)
    {
        // Get the type of the nested class.
        Type myTypeB = MyClassA.MyClassB.class.ToType();

        // Get the IsNestedPrivate property of the nested class.
        Console.WriteLine("\nThe IsNestedPrivate property value of the nested"
            +" class is {0}.",
            System.Convert.ToString(myTypeB.get_IsNestedPrivate()));
    } //main
} //MyClassA

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

Type 类
Type 成员
System 命名空间
TypeAttributes