Type.IsInterface Egenskap
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar ett värde som anger om Type är ett gränssnitt, dvs. inte en klass eller en värdetyp.
public:
property bool IsInterface { bool get(); };
public bool IsInterface { get; }
member this.IsInterface : bool
Public ReadOnly Property IsInterface As Boolean
Egenskapsvärde
true
Type om är ett gränssnitt, annars . false
Implementeringar
Exempel
I följande exempel skapas ett gränssnitt, söker efter gränssnittstypen och anger om en klass har egenskapsuppsättningen IsInterface .
using System;
// Declare an interface.
interface myIFace
{
}
class MyIsInterface
{
public static void Main(string []args)
{
try
{
// Get the IsInterface attribute for myIFace.
bool myBool1 = typeof(myIFace).IsInterface;
//Display the IsInterface attribute for myIFace.
Console.WriteLine("Is the specified type an interface? {0}.", myBool1);
// Get the attribute IsInterface for MyIsInterface.
bool myBool2 = typeof(MyIsInterface).IsInterface;
//Display the IsInterface attribute for MyIsInterface.
Console.WriteLine("Is the specified type an interface? {0}.", myBool2);
}
catch(Exception e)
{
Console.WriteLine("\nAn exception occurred: {0}.", e.Message);
}
}
}
/* The example produces the following output:
Is the specified type an interface? True.
Is the specified type an interface? False.
*/
// Declare an interface.
type myIFace = interface end
type MyIsInterface = class end
try
// Get the IsInterface attribute for myIFace.
let myBool1 = typeof<myIFace>.IsInterface
//Display the IsInterface attribute for myIFace.
printfn $"Is the specified type an interface? {myBool1}."
// Get the attribute IsInterface for MyIsInterface.
let myBool2 = typeof<MyIsInterface>.IsInterface
//Display the IsInterface attribute for MyIsInterface.
printfn $"Is the specified type an interface? {myBool2}."
with e ->
printfn $"\nAn exception occurred: {e.Message}."
(* The example produces the following output:
Is the specified type an interface? True.
Is the specified type an interface? False.
*)
' Declare an interface.
Interface myIFace
End Interface
Class MyIsInterface
Public Shared Sub Main()
' Get the IsInterface attribute for myIFace.
Dim myBool1 As Boolean = GetType(myIFace).IsInterface
Console.WriteLine("Is the specified type an interface? {0}.", myBool1)
' Determine whether Example is an interface.
Dim myBool2 As Boolean = GetType(MyIsInterface).IsInterface
Console.WriteLine("Is the specified type an interface? {0}.", myBool2)
Console.ReadLine()
End Sub
End Class
' The example displays the following output:
' Is the specified type an interface? True.
' Is the specified type an interface? False.
Kommentarer
Särskiljer ClassSemanticsMask en typdeklaration som klass, gränssnitt eller värdetyp.
Om strömmen Type representerar en typparameter i definitionen av en allmän typ eller allmän metod returnerar falseden här egenskapen alltid .
Den här egenskapen är skrivskyddad.