Ler em inglês

Partilhar via


Type.IsSealed Propriedade

Definição

Obtém um valor que indica se o Type está declarado selado.

C#
public bool IsSealed { get; }

Valor da propriedade

Boolean

true se o Type for declarado lacrado; caso contrário, false .

Implementações

Exemplos

O exemplo a seguir cria uma instância de uma classe, verifica a sealed propriedade e exibe o IsSealed resultado.

C#
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.

Comentários

Caso o Type atual represente um parâmetro de tipo de um tipo genérico, esta propriedade sempre retorna true.

Aplica-se a

Produto Versões
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
.NET Standard 2.0, 2.1

Confira também