CodeVariableDeclarationStatement
メンバ
コンストラクタ
- public CodeVariableDeclarationStatement();
-
- 概要
- System.CodeDom.CodeVariableDeclarationStatement クラスの新しいインスタンスを初期化します。
- public CodeVariableDeclarationStatement( CodeTypeReference type, string name );
-
- 概要
- 新しいインスタンスを初期化、 System.CodeDom.CodeVariableDeclarationStatement クラスの指定した型と名を使用します。
- パラメーター
-
- type
- A System.CodeDom.CodeTypeReference 変数のデータ型を示します。
- name
- 変数の名前。
- 例
-
// 生成 CodeVariableDeclarationStatement cvds = new CodeVariableDeclarationStatement( new CodeTypeReference( typeof( int ) ), "IntData" ); // int IntData;
- public CodeVariableDeclarationStatement( string type, string name );
-
- 概要
- 新しいインスタンスを初期化、 System.CodeDom.CodeVariableDeclarationStatement クラスの指定されたデータ型の名前と変数名を使用します。
- パラメーター
-
- type
- 変数のデータ型の名前。
- name
- 変数の名前。
- 例
-
// 生成 CodeVariableDeclarationStatement cvds = new CodeVariableDeclarationStatement( "double", "DoubleData" ); // @double DoubleData;
- public CodeVariableDeclarationStatement( Type type, string name );
-
- 概要
- 新しいインスタンスを初期化、 System.CodeDom.CodeVariableDeclarationStatement クラスの指定されたデータ型と変数名を使用します。
- パラメーター
-
- type
- データは、変数を型します。
- name
- 変数の名前。
- 例
-
// 生成 CodeVariableDeclarationStatement cvds = new CodeVariableDeclarationStatement( typeof( byte ), "ByteData" ); // byte ByteData;
- public CodeVariableDeclarationStatement( CodeTypeReference type, string name, CodeExpression initExpression );
-
- 概要
- 新しいインスタンスを初期化、 System.CodeDom.CodeVariableDeclarationStatement クラスの指定されたデータ型、変数名、および初期化式を使用します。
- パラメーター
-
- type
- A System.CodeDom.CodeTypeReference 変数の型を示します。
- name
- 変数の名前。
- initExpression
- A System.CodeDom.CodeExpression 変数の初期化式を示します。
- 例
-
// 生成 CodeVariableDeclarationStatement cvds = new CodeVariableDeclarationStatement( new CodeTypeReference( typeof( string ) ), "StringData", new CodePrimitiveExpression( "テストデータ" ) ); // string StringData = "テストデータ";
- public CodeVariableDeclarationStatement( string type, string name, CodeExpression initExpression );
-
- 概要
- 新しいインスタンスを初期化、 System.CodeDom.CodeVariableDeclarationStatement クラスの指定されたデータ型、変数名、および初期化式を使用します。
- パラメーター
-
- type
- 変数のデータ型の名前。
- name
- 変数の名前。
- initExpression
- A System.CodeDom.CodeExpression 変数の初期化式を示します。
- 例
-
// 生成 CodeVariableDeclarationStatement cvds = new CodeVariableDeclarationStatement( "int", "IntData", new CodePrimitiveExpression( 100 ) ); // @int IntData = 100;
- public CodeVariableDeclarationStatement( Type type, string name, CodeExpression initExpression );
-
- 概要
- 新しいインスタンスを初期化、 System.CodeDom.CodeVariableDeclarationStatement クラスの指定されたデータ型、変数名、および初期化式を使用します。
- パラメーター
-
- type
- 変数のデータ型。
- name
- 変数の名前。
- initExpression
- A System.CodeDom.CodeExpression 変数の初期化式を示します。
- 例
-
// 生成 CodeVariableDeclarationStatement cvds = new CodeVariableDeclarationStatement( typeof( int ), "IntData", new CodePrimitiveExpression( 100 ) ); // int IntData = 100;
プロパティ
- public CodeExpression InitExpression{ get; set; }
-
- 概要
- 変数の初期化式を取得または設定します。
- 戻り値
- A System.CodeDom.CodeExpression 変数の初期化式を示します。
- public string Name{ get; set; }
-
- 概要
- 変数の名前を取得または設定します。
- 戻り値
- 変数の名前。
- public CodeTypeReference Type{ get; set; }
-
- 概要
- 変数のデータ型を取得または設定します。
- 戻り値
- A System.CodeDom.CodeTypeReference 変数のデータ型を示します。
- EndDirectives
- 終了ディレクティブを含むCodeDirectiveCollectionオブジェクトを取得します。 (Inherited from CodeStatement )
- LinePragma
- コードステートメントが発生する行を取得または設定します。 (Inherited from CodeStatement )
- StartDirectives
- 開始ディレクティブを含むCodeDirectiveCollectionオブジェクトを取得します。 (Inherited from CodeStatement )
- UserData
- 現在のオブジェクトのユーザー定義可能データを取得します。 (Inherited from CodeObject )
メソッド
- Equals(Object)
- 指定したオブジェクトが現在のオブジェクトと等しいかどうかを確認します。 (Inherited from Object)
- GetHashCode()
- デフォルトのハッシュ関数として機能します。 (Inherited from Object)
- GetType()
- 現在のインスタンスのTypeを取得します。 (Inherited from Object)
- MemberwiseClone()
- 現在のObjectの簡易コピーを作成します。 (Inherited from Object)
- ToString()
- 現在のオブジェクトを表す文字列を返します。 (Inherited from Object)
例
この例では、CodeVariableDeclarationStatementを使用して変数を宣言する方法を示します。
CodeVariableDeclarationStatement variableDeclaration =
new CodeVariableDeclarationStatement(
// Type of the variable to declare.
// 宣言する変数のタイプ。
typeof( string ),
// Name of the variable to declare.
// 宣言する変数の名前。
"TestString",
// Optional initExpression parameter initializes the variable.
// オプションのinitExpressionパラメータは変数を初期設定する。
new CodePrimitiveExpression( "Testing" )
);
// A C# code generator produces the following source code for the preceeding example code:
// A C#コードジェネレータはpreceeding例コードのための以下のソースコードを作り出す:
// string TestString = "Testing";
定義
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Serializable]
public class CodeVariableDeclarationStatement : System.CodeDom.CodeStatement
クラス
#region アセンブリ System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// C:¥Program Files (x86)¥Reference Assemblies¥Microsoft¥Framework¥.NETFramework¥v4.6.1¥System.dll
#endregion
using System.Runtime.InteropServices;
namespace System.CodeDom
{
//
// 概要:
// 変数の宣言を表します。
[ClassInterface( ClassInterfaceType.AutoDispatch )]
[ComVisible( true )]
public class CodeVariableDeclarationStatement : CodeStatement
{
//
// 概要:
// System.CodeDom.CodeVariableDeclarationStatement クラスの新しいインスタンスを初期化します。
public CodeVariableDeclarationStatement();
//
// 概要:
// 新しいインスタンスを初期化、 System.CodeDom.CodeVariableDeclarationStatement クラスの指定した型と名を使用します。
//
// パラメーター:
// type:
// A System.CodeDom.CodeTypeReference 変数のデータ型を示します。
//
// name:
// 変数の名前。
public CodeVariableDeclarationStatement( CodeTypeReference type, string name );
//
// 概要:
// 新しいインスタンスを初期化、 System.CodeDom.CodeVariableDeclarationStatement クラスの指定されたデータ型の名前と変数名を使用します。
//
// パラメーター:
// type:
// 変数のデータ型の名前。
//
// name:
// 変数の名前。
public CodeVariableDeclarationStatement( string type, string name );
//
// 概要:
// 新しいインスタンスを初期化、 System.CodeDom.CodeVariableDeclarationStatement クラスの指定されたデータ型と変数名を使用します。
//
// パラメーター:
// type:
// データは、変数を型します。
//
// name:
// 変数の名前。
public CodeVariableDeclarationStatement( Type type, string name );
//
// 概要:
// 新しいインスタンスを初期化、 System.CodeDom.CodeVariableDeclarationStatement クラスの指定されたデータ型、変数名、および初期化式を使用します。
//
// パラメーター:
// type:
// A System.CodeDom.CodeTypeReference 変数の型を示します。
//
// name:
// 変数の名前。
//
// initExpression:
// A System.CodeDom.CodeExpression 変数の初期化式を示します。
public CodeVariableDeclarationStatement( CodeTypeReference type, string name, CodeExpression initExpression );
//
// 概要:
// 新しいインスタンスを初期化、 System.CodeDom.CodeVariableDeclarationStatement クラスの指定されたデータ型、変数名、および初期化式を使用します。
//
// パラメーター:
// type:
// 変数のデータ型の名前。
//
// name:
// 変数の名前。
//
// initExpression:
// A System.CodeDom.CodeExpression 変数の初期化式を示します。
public CodeVariableDeclarationStatement( string type, string name, CodeExpression initExpression );
//
// 概要:
// 新しいインスタンスを初期化、 System.CodeDom.CodeVariableDeclarationStatement クラスの指定されたデータ型、変数名、および初期化式を使用します。
//
// パラメーター:
// type:
// 変数のデータ型。
//
// name:
// 変数の名前。
//
// initExpression:
// A System.CodeDom.CodeExpression 変数の初期化式を示します。
public CodeVariableDeclarationStatement( Type type, string name, CodeExpression initExpression );
//
// 概要:
// 取得または変数の初期化式を設定します。
//
// 戻り値:
// A System.CodeDom.CodeExpression 変数の初期化式を示します。
public CodeExpression InitExpression
{
get;
set;
}
//
// 概要:
// 取得または変数の名前を設定します。
//
// 戻り値:
// 変数の名前。
public string Name
{
get;
set;
}
//
// 概要:
// 取得または変数のデータ型を設定します。
//
// 戻り値:
// A System.CodeDom.CodeTypeReference 変数のデータ型を示します。
public CodeTypeReference Type
{
get;
set;
}
}
}