Type.IsPublic 속성

정의

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

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

속성 값

Boolean

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

구현

예제

다음 예에서는의 인스턴스를 만들고 MyTestClass , IsPublic 속성을 확인 하 고, 결과를 표시 합니다.

using namespace System;

// Declare MyTestClass as public.
public ref class TestClass{};

int main()
{
   TestClass^ testClassInstance = gcnew TestClass;
   
   // Get the type of myTestClassInstance.
   Type^ testType = testClassInstance->GetType();
   
   // Get the IsPublic property of the myTestClassInstance.
   bool isPublic = testType->IsPublic;
   Console::WriteLine( "Is {0} public? {1}", testType->FullName, isPublic);
}
using System;

public class TestClass
{
}

public class Example
{
   public static void Main()
   {
      TestClass testClassInstance = new TestClass();
      // Get the type of myTestClassInstance.
      Type   testType = testClassInstance.GetType();
      // Get the IsPublic property of testClassInstance.
      bool isPublic = testType.IsPublic;
      Console.WriteLine("Is {0} public? {1}", testType.FullName, isPublic);
   }
}
// The example displays the following output:
//        Is TestClass public? True
Public Class TestClass
End Class

Public Class Example
   Public Shared Sub Main()
      Dim testClassInstance As New TestClass()
      
      ' Get the type of testClassInstance.
      Dim testType As Type = testClassInstance.GetType()
      ' Get the IsPublic property of testClassInstance.
      Dim isPublic As Boolean = testType.IsPublic
      Console.WriteLine("Is {0} public? {1}", testType.FullName, isPublic)
   End Sub 
End Class 
' The example displays the following output:
'       Is TestClass public? True

중첩 된 클래스의 경우 및의 결과를 무시 하 고 IsPublic IsNotPublic 및의 결과에만 주의를 기울여야 합니다 IsNestedPublic IsNestedPrivate .

설명

중첩 형식에는를 사용 하지 마십시오. IsNestedPublic 대신를 사용 합니다.

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

TypeAttributes.VisibilityMask 표시 유형 특성을 선택 합니다.

적용 대상

추가 정보