Type.IsNotPublic 속성

정의

Type이 public으로 선언되어 있지 않은지 여부를 나타내는 값을 가져옵니다.

public:
 property bool IsNotPublic { bool get(); };
public bool IsNotPublic { get; }
member this.IsNotPublic : bool
Public ReadOnly Property IsNotPublic As Boolean

속성 값

Boolean

true이 public으로 선언되어 있지 않고 중첩 형식이 아니면 Type이고, 그렇지 않으면 false입니다.

구현

예제

이 예제에서는 IsNotPublic 속성을 사용하여 형식의 표시 유형을 표시합니다.

using namespace System;
using namespace System::IO;
using namespace System::Reflection;

int main()
{
   //Get the Type and MemberInfo.
   Type^ t = Type::GetType("System.IO.File");
   array<MemberInfo^>^ members = t->GetMembers();
   
   //Get and display the DeclaringType method.
   Console::WriteLine("There are {0} members in {1}.",
                      members->Length, t->FullName );
   Console::WriteLine("Is {0} non-public? {1}",
                      t->FullName, t->IsNotPublic );
}
// The example displays the following output:
//       There are 60 members in System.IO.File.
//       Is System.IO.File non-public? False
using System;
using System.IO;
using System.Reflection;

class Example
{
    public static void Main()
    {
        // Get the Type and MemberInfo.
        Type t = Type.GetType("System.IO.File");
        MemberInfo[] members = t.GetMembers();
        // Get and display the DeclaringType method.
        Console.WriteLine("\nThere are {0} members in {1}.",
                          members.Length, t.FullName);
        Console.WriteLine("Is {0} non-public? {1}",
                          t.FullName, t.IsNotPublic);
    }
}
// The example displays output like the following:
//       There are 60 members in System.IO.File.
//       Is System.IO.File non-public? False
Imports System.IO
Imports System.Reflection

Module Example
    Public Sub Main()
        'Get the Type and MemberInfo.
        Dim t As Type = Type.GetType("System.IO.File")
        Dim members As MemberInfo() = t.GetMembers()
        'Get and display the DeclaringType method.
        Console.WriteLine("There are {0} members in {1}.",
                          members.Length, t.FullName)
        Console.WriteLine("Is {0} non-public? {1}",
                          t.FullName, t.IsNotPublic)
    End Sub
End Module
' The example displays output like the following:
'       There are 60 members in System.IO.File.
'       Is System.IO.File non-public? False

다음 코드 예제에서는 IsPublic 중첩된 클래스에 및 를 사용할 수 없는 이유를 IsNotPublic 보여 있습니다.

public ref class A
{
public:
   ref class B{};


private:
   ref class C{};


};
public class A
{
    public class B { }
    private class C { }
}
Public Class A
    Public Class B
    End Class
    Private Class C
    End Class
End Class

중첩 클래스의 경우 및 의 결과를 무시하고 IsPublic IsNotPublic 및 의 결과에만 주의합니다. IsNestedPublic IsNestedPrivate 이 코드 조각에 대한 리플렉션 출력은 다음과 같습니다.

클래스 IsNotPublic IsPublic IsNestedPublic IsNestedPrivate
A FALSE TRUE FALSE FALSE
B FALSE FALSE TRUE FALSE
C FALSE FALSE FALSE TRUE

설명

중첩된 형식에는 이 속성을 사용하지 마십시오. 대신 IsNestedPublic 속성을 사용합니다.

현재 가 Type 제네릭 형식의 형식 매개 변수를 나타내는 경우 이 속성은 false 를 반환합니다.

적용 대상

추가 정보