Type.IsSealed Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene un valore che indica se Type è dichiarato sealed.
public:
property bool IsSealed { bool get(); };
public bool IsSealed { get; }
member this.IsSealed : bool
Public ReadOnly Property IsSealed As Boolean
Valore della proprietà
true
se Type è dichiarato sealed; in caso contrario, false
.
Implementazioni
Esempio
Nell'esempio seguente viene creata un'istanza di una sealed
classe , viene verificata la IsSealed
proprietà e viene visualizzato il risultato.
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.
module Example
// Declare InnerClass as sealed.
[<Sealed>]
type InnerClass() = class end
let inner = InnerClass()
// Get the type of InnerClass.
let innerType = inner.GetType()
// Get the IsSealed property of innerClass.
let isSealed = innerType.IsSealed
printfn $"{innerType.FullName} is sealed: {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.
Commenti
Se l'oggetto corrente Type rappresenta un parametro di tipo di un tipo generico, questa proprietà restituisce true
sempre .