Type.IsSealed Type.IsSealed Type.IsSealed Type.IsSealed Property

정의

Type이 봉인된 형식으로 선언되어 있는지 여부를 나타내는 값을 가져옵니다.Gets a value indicating whether the Type is declared sealed.

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

속성 값

true이 봉인된 형식으로 선언되어 있으면 Type이고, 그렇지 않으면 false입니다.true if the Type is declared sealed; otherwise, false.

구현

예제

다음 예제에서는 인스턴스를 만듭니다는 sealed 클래스에 대 한 검사는 IsSealed 속성 결과 표시 합니다.The following example creates an instance of a sealed class, checks for the IsSealed property, and displays the result.

using namespace System;

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

int main()
{
      TestClass^ testClassInstance = gcnew TestClass;
      
      // Get the type of testClassInstance.
      Type^ type = testClassInstance->GetType();
      
      // Get the IsSealed property of the myTestClassInstance.
      bool sealed = type->IsSealed;
      Console::WriteLine("{0} is sealed: {1}.", type->FullName, sealed);
}
// The example displays the following output:
//        TestClass is sealed: True.
using System;

 public class Example
 {
     // Declare InnerClass as sealed.
     sealed public class InnerClass
     {
     }

     public static void Main()
     {
          InnerClass inner = new InnerClass();
          // Get the type of InnerClass.
          Type innerType = inner.GetType();
          // Get the IsSealed property of  innerClass.
          bool isSealed = innerType.IsSealed;
          Console.WriteLine("{0} is sealed: {1}.", innerType.FullName, isSealed);
     }
}
// The example displays the following output:
//        Example+InnerClass is sealed: True.
Public Class Example
    ' Declare InnerClass as sealed.
    Public NotInheritable Class InnerClass
    End Class
    
    Public Shared Sub Main()
         Dim inner As New InnerClass()
         ' Get the type of InnerClass.
         Dim innerType As Type = inner.GetType()
         ' Get the IsSealed property of InnerClass.
         Dim sealed As Boolean = innerType.IsSealed
         Console.WriteLine("{0} is sealed: {1}.", innerType.FullName, sealed)
    End Sub
End Class
' The example displays the following output:
'       Example+InnerClass is sealed: True.

설명

하는 경우 현재 Type 이 속성은 항상 반환 제네릭 형식의 형식 매개 변수를 나타내는 true합니다.If the current Type represents a type parameter of a generic type, this property always returns true.

적용 대상

추가 정보