Type.IsPublic 속성
정의
public:
property bool IsPublic { bool get(); };
public bool IsPublic { get; }
member this.IsPublic : bool
Public ReadOnly Property IsPublic As Boolean
속성 값
true
이 public으로 선언되어 있고 중첩 형식이 아니면 Type이고, 그렇지 않으면 false
입니다.true
if the Type is declared public and is not a nested type; otherwise, false
.
구현
예제
다음 예제에서는 인스턴스를 만듭니다 MyTestClass
, 확인을 IsPublic
속성 결과 표시 합니다.The following example creates an instance of MyTestClass
, checks for the IsPublic
property, and displays the result.
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합니다.For nested classes, ignore the results of IsPublic
and IsNotPublic
and pay attention only to the results of IsNestedPublic and IsNestedPrivate.
설명
중첩 된 형식을 사용 안 함 사용 하 여 IsNestedPublic 대신 합니다.Do not use with nested types; use IsNestedPublic instead.
하는 경우 현재 Type 이 속성을 반환 합니다. 제네릭 형식의 형식 매개 변수를 나타내는 true
합니다.If the current Type represents a type parameter of a generic type, this property returns true
.
TypeAttributes.VisibilityMask 표시 유형 특성을 선택합니다.TypeAttributes.VisibilityMask selects the visibility attributes.