CodeCastExpression-Klasse
Stellt einen Ausdruck dar, der in einen Datentyp oder in eine Schnittstelle umgewandelt wird.
Namespace: System.CodeDom
Assembly: System (in system.dll)
Syntax
'Declaration
<SerializableAttribute> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class CodeCastExpression
Inherits CodeExpression
'Usage
Dim instance As CodeCastExpression
[SerializableAttribute]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
[ComVisibleAttribute(true)]
public class CodeCastExpression : CodeExpression
[SerializableAttribute]
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)]
[ComVisibleAttribute(true)]
public ref class CodeCastExpression : public CodeExpression
/** @attribute SerializableAttribute() */
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */
/** @attribute ComVisibleAttribute(true) */
public class CodeCastExpression extends CodeExpression
SerializableAttribute
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)
ComVisibleAttribute(true)
public class CodeCastExpression extends CodeExpression
Hinweise
Mit CodeCastExpression kann ein Ausdruck dargestellt werden, der in einen anderen Datentyp oder in eine Schnittstelle umgewandelt wird.
Die Expression-Eigenschaft gibt die umzuwandelnde CodeExpression an. Die TargetType-Eigenschaft gibt den Zieltyp für die Umwandlung an.
Beispiel
In diesem Beispiel wird veranschaulicht, wie mit einer CodeCastExpression ein System.Int32-Wert in einen System.Int64-Datentyp umgewandelt wird.
' This CodeCastExpression casts an Int32 of 1000 to an Int64.
Dim castExpression As New CodeCastExpression( _
"System.Int64", New CodePrimitiveExpression(1000) )
' A Visual Basic code generator produces the following source code for the preceeding example code:
' CType(1000,Long)
// This CodeCastExpression casts an Int32 of 1000 to an Int64.
CodeCastExpression castExpression = new CodeCastExpression(
// targetType parameter indicating the target type of the cast.
"System.Int64",
// The CodeExpression to cast, here an Int32 value of 1000.
new CodePrimitiveExpression(1000) );
// A C# code generator produces the following source code for the preceeding example code:
// ((long)(1000));
// This CodeCastExpression casts an Int32 of 1000 to an Int64.
// targetType parameter indicating the target type of the cast.
// The CodeExpression to cast, here an Int32 value of 1000.
CodeCastExpression^ castExpression = gcnew CodeCastExpression( "System.Int64",gcnew CodePrimitiveExpression( 1000 ) );
// A C# code generator produces the following source code for the preceeding example code:
// ((long)(1000));
// This CodeCastExpression casts an Int32 of 1000 to an Int64.
CodeCastExpression castExpression = new CodeCastExpression(
// targetType parameter indicating the target type of the cast.
"System.Int64",
// The CodeExpression to cast, here an Int32 value of 1000.
new CodePrimitiveExpression(System.Convert.ToString(1000)));
// A VJ# code generator produces the following source code for
// the preceeding example code:
// (System.Convert.ToInt64(1000));
Vererbungshierarchie
System.Object
System.CodeDom.CodeObject
System.CodeDom.CodeExpression
System.CodeDom.CodeCastExpression
Threadsicherheit
Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.
Plattformen
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
CodeCastExpression-Member
System.CodeDom-Namespace
CodeExpression