次の方法で共有


CodeCastExpression クラス

データ型またはインターフェイスにキャストする式を表します。

この型のすべてのメンバの一覧については、CodeCastExpression メンバ を参照してください。

System.Object
   System.CodeDom.CodeObject
      System.CodeDom.CodeExpression
         System.CodeDom.CodeCastExpression

<Serializable>
<ClassInterface(ClassInterfaceType.AutoDispatch)>
<ComVisible(True)>
Public Class CodeCastExpression   Inherits CodeExpression
[C#]
[Serializable]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[ComVisible(true)]
public class CodeCastExpression : CodeExpression
[C++]
[Serializable]
[ClassInterface(ClassInterfaceType::AutoDispatch)]
[ComVisible(true)]
public __gc class CodeCastExpression : public CodeExpression
[JScript]
public
   Serializable
 ClassInterface(ClassInterfaceType.AutoDispatch)
 ComVisible(true)
class CodeCastExpression extends CodeExpression

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

解説

CodeCastExpression を使用して、別のデータ型またはインターフェイスにキャストする式を表すことができます。

Expression プロパティは、キャストする CodeExpression を示します。 TargetType プロパティは、キャスト先の型を示します。

使用例

[Visual Basic, C#, C++] CodeCastExpression を使用して、 System.Int32 の値を System.Int64 のデータ型にキャストする例を次に示します。

 
' 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)

[C#] 
// 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));

[C++] 
// This CodeCastExpression casts an Int32 of 1000 to an Int64.        
CodeCastExpression* castExpression = new CodeCastExpression(
    // targetType parameter indicating the target type of the cast.
    S"System.Int64",
    // The CodeExpression to cast, here an Int32 value of 1000.
    new CodePrimitiveExpression(__box(1000)) );    

// A C# code generator produces the following source code for the preceeding example code:

// ((long)(1000));

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

名前空間: System.CodeDom

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

アセンブリ: System (System.dll 内)

参照

CodeCastExpression メンバ | System.CodeDom 名前空間 | CodeExpression