CodeCastExpression Klasa

Definicja

Reprezentuje rzutowanie wyrażenia na typ danych lub interfejs.

public ref class CodeCastExpression : System::CodeDom::CodeExpression
public class CodeCastExpression : System.CodeDom.CodeExpression
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeCastExpression : System.CodeDom.CodeExpression
type CodeCastExpression = class
    inherit CodeExpression
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeCastExpression = class
    inherit CodeExpression
Public Class CodeCastExpression
Inherits CodeExpression
Dziedziczenie
CodeCastExpression
Atrybuty

Przykłady

W tym przykładzie pokazano użycie elementu , CodeCastExpression aby rzutować System.Int32 wartość na System.Int64 typ danych.

// 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(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.		
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)

Uwagi

CodeCastExpression może służyć do reprezentowania rzutowania wyrażenia na inny typ danych lub interfejs.

Właściwość Expression wskazuje właściwość do rzutowania CodeExpression . Właściwość TargetType wskazuje typ do rzutowania.

Konstruktory

CodeCastExpression()

Inicjuje nowe wystąpienie klasy CodeCastExpression.

CodeCastExpression(CodeTypeReference, CodeExpression)

Inicjuje CodeCastExpression nowe wystąpienie klasy przy użyciu określonego typu docelowego i wyrażenia.

CodeCastExpression(String, CodeExpression)

Inicjuje CodeCastExpression nowe wystąpienie klasy przy użyciu określonego typu docelowego i wyrażenia.

CodeCastExpression(Type, CodeExpression)

Inicjuje CodeCastExpression nowe wystąpienie klasy przy użyciu określonego typu docelowego i wyrażenia.

Właściwości

Expression

Pobiera lub ustawia wyrażenie na rzutowanie.

TargetType

Pobiera lub ustawia typ docelowy rzutowania.

UserData

Pobiera dane zdefiniowane przez użytkownika dla bieżącego obiektu.

(Odziedziczone po CodeObject)

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy

Zobacz też