Type.IsPublic 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
Type public으로 선언되었는지 여부를 나타내는 값을 가져옵니다.
public:
property bool IsPublic { bool get(); };
public bool IsPublic { get; }
member this.IsPublic : bool
Public ReadOnly Property IsPublic As Boolean
속성 값
true public으로 Type 선언되고 중첩된 형식이 아니면 .이고, false그렇지 않으면 .
구현
예제
다음 예제에서는 인스턴스 MyTestClass를 만들고 속성을 확인하고 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
type TestClass() = class end
let testClassInstance = TestClass()
// Get the type of myTestClassInstance.
let testType = testClassInstance.GetType()
// Get the IsPublic property of testClassInstance.
let isPublic = testType.IsPublic
printfn $"Is {testType.FullName} public? {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 경우 결과를 무시하고 결과 IsNotPublicIsNestedPublic와 IsNestedPrivate 결과에만 주의해야 합니다.
설명
중첩된 형식에는 사용하지 마세요. 대신 사용합니다 IsNestedPublic .
현재 Type 제네릭 형식의 형식 매개 변수를 나타내는 경우 이 속성은 반환됩니다 true.
TypeAttributes.VisibilityMask 표시 유형 특성을 선택합니다.