CodeLabeledStatementとは? わかりやすく解説

CodeLabeledStatement クラス

ラベル付きステートメントまたはスタンドアロンラベル表します

名前空間: System.CodeDom
アセンブリ: System (system.dll 内)
構文構文

<SerializableAttribute> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class CodeLabeledStatement
    Inherits CodeStatement
Dim instance As CodeLabeledStatement
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public class CodeLabeledStatement : CodeStatement
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
[ComVisibleAttribute(true)] 
public ref class CodeLabeledStatement : public
 CodeStatement
/** @attribute SerializableAttribute() */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class CodeLabeledStatement extends CodeStatement
SerializableAttribute 
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public class CodeLabeledStatement extends
 CodeStatement
解説解説

CodeLabeledStatement は、ラベル、および省略可能な関連付けられているステートメント表しますラベル使用して、CodeGotoStatement の対象を示すことができます

Statement プロパティ省略可能です。ラベルだけを作成するには、Statement プロパティ初期化する前の状態のままにします。

メモメモ

goto ステートメントおよびラベルは、すべての言語サポートされているわけではありません。コード ジェネレータgoto ステートメントおよびラベルサポートしているかどうか調べるには、GotoStatements フラグ使用して Supports メソッド呼び出します。

使用例使用例

CodeGotoStatementCodeLabeledStatement使用してプログラムのフローリダイレクトする例を次に示します

' Declares a type to contain the example code.
Dim type1 As New CodeTypeDeclaration("Type1")
' Declares an entry point method.
Dim entry1 As New CodeEntryPointMethod()
type1.Members.Add(entry1)
' Adds a goto statement to continue program flow at the "JumpToLabel"
 label.
Dim goto1 As New CodeGotoStatement("JumpToLabel")
entry1.Statements.Add(goto1)
' Invokes Console.WriteLine to print "Test Output", which
 is skipped by the goto statement.
Dim method1 As New CodeMethodInvokeExpression(New
 CodeTypeReferenceExpression("System.Console"), "WriteLine",
 New CodePrimitiveExpression("Test Output."))
entry1.Statements.Add(method1)
' Declares a label named "JumpToLabel" associated with a method
 to output a test string using Console.WriteLine.
Dim method2 As New CodeMethodInvokeExpression(New
 CodeTypeReferenceExpression("System.Console"), "WriteLine",
 New CodePrimitiveExpression("Output from labeled statement."))
Dim label1 As New CodeLabeledStatement("JumpToLabel",
 New CodeExpressionStatement(method2))
entry1.Statements.Add(label1)

' A Visual Basic code generator produces the following source code for
 the preceeding example code:

'   Public Class Type1
'
'       Public Shared Sub Main()
'           GoTo JumpToLabel
'           System.Console.WriteLine("Test Output")
'           JumpToLabel:
'           System.Console.WriteLine("Output from labeled statement.")
'       End Sub
'   End Class
// Declares a type to contain the example code.
CodeTypeDeclaration type1 = new CodeTypeDeclaration("Type1");
            
// Declares an entry point method.
CodeEntryPointMethod entry1 = new CodeEntryPointMethod();    
                    
type1.Members.Add( entry1 );
// Adds a goto statement to continue program flow at the "JumpToLabel"
 label.
CodeGotoStatement goto1 = new CodeGotoStatement("JumpToLabel");
entry1.Statements.Add( goto1 );
// Invokes Console.WriteLine to print "Test Output", which
 is skipped by the goto statement.
CodeMethodInvokeExpression method1 = new CodeMethodInvokeExpression(
    new CodeTypeReferenceExpression("System.Console"),
 "WriteLine", new CodePrimitiveExpression("Test
 Output."));
entry1.Statements.Add( method1 );
// Declares a label named "JumpToLabel" associated with a
 method to output a test string using Console.WriteLine.
CodeMethodInvokeExpression method2 = new CodeMethodInvokeExpression(
    new CodeTypeReferenceExpression("System.Console"),
 "WriteLine", new CodePrimitiveExpression("Output
 from labeled statement."));
CodeLabeledStatement label1 = new CodeLabeledStatement("JumpToLabel",
 new CodeExpressionStatement(method2) );
entry1.Statements.Add( label1 );

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

//    public class Type1 
//    {
//        
//        public static void Main() 
//        {
//            goto JumpToLabel;
//            System.Console.WriteLine("Test Output");
//            JumpToLabel:
//            System.Console.WriteLine("Output from labeled statement.");
//        }
//    }
// Declares a type to contain the example code.
CodeTypeDeclaration^ type1 = gcnew CodeTypeDeclaration( "Type1" );

// Declares an entry point method.
CodeEntryPointMethod^ entry1 = gcnew CodeEntryPointMethod;
type1->Members->Add( entry1 );

// Adds a goto statement to continue program flow at the "JumpToLabel"
 label.
CodeGotoStatement^ goto1 = gcnew CodeGotoStatement( "JumpToLabel" );
entry1->Statements->Add( goto1 );

// Invokes Console.WriteLine to print "Test Output", which
 is skipped by the goto statement.
array<CodeExpression^>^temp = {gcnew CodePrimitiveExpression( "Test Output."
 )};
CodeMethodInvokeExpression^ method1 = gcnew CodeMethodInvokeExpression( gcnew CodeTypeReferenceExpression(
 "System.Console" ),"WriteLine",temp );
entry1->Statements->Add( method1 );

// Declares a label named "JumpToLabel" associated with a
 method to output a test string using Console.WriteLine.
array<CodeExpression^>^temp2 = {gcnew CodePrimitiveExpression( "Output
 from labeled statement." )};
CodeMethodInvokeExpression^ method2 = gcnew CodeMethodInvokeExpression( gcnew CodeTypeReferenceExpression(
 "System.Console" ),"WriteLine",temp2 );
CodeLabeledStatement^ label1 = gcnew CodeLabeledStatement( "JumpToLabel",gcnew
 CodeExpressionStatement( method2 ) );
entry1->Statements->Add( label1 );

// A C# code generator produces the following source code for the preceeding
 example code:
//    public class Type1 
//    {
//        
//        public static void Main() 
//        {
//            goto JumpToLabel;
//            System.Console.WriteLine("Test Output");
//            JumpToLabel:
//            System.Console.WriteLine("Output from labeled statement.");
//        }
//    }
// Declares a type to contain the example code.
CodeTypeDeclaration type1 = new CodeTypeDeclaration("Type1");
// Declares an entry point method.
CodeEntryPointMethod entry1 = new CodeEntryPointMethod();
type1.get_Members().Add(entry1);
// Adds a goto statement to continue program flow at the 
// "JumpToLabel" label.
CodeGotoStatement goto1 = new CodeGotoStatement("JumpToLabel");
entry1.get_Statements().Add(goto1);
// Invokes Console.WriteLine to print "Test Output", which
 is 
// skipped by the goto statement.
CodeMethodInvokeExpression method1 = new CodeMethodInvokeExpression
    (new CodeTypeReferenceExpression("System.Console"),
 
    "WriteLine", new CodePrimitiveExpression[] { new
 
    CodePrimitiveExpression("Test Output.") });
entry1.get_Statements().Add(method1);
// Declares a label named "JumpToLabel" associated with a
 method to
// output a test string using Console.WriteLine.
CodeMethodInvokeExpression method2 = new 
    CodeMethodInvokeExpression(new CodeTypeReferenceExpression(
    "System.Console"), "WriteLine", new CodePrimitiveExpression[]
 
    { new CodePrimitiveExpression("Output from labeled statement.")
 });
CodeLabeledStatement label1 = new CodeLabeledStatement("JumpToLabel",
 
    new CodeExpressionStatement(method2));
entry1.get_Statements().Add(label1);
// A VJ# code generator produces the following source code for the 
// preceeding example code:
// public class Type1 
// {
//     public static void main() 
//     {
//         goto JumpToLabel;
//         System.Console.WriteLine("Test Output");
//         JumpToLabel:
//         System.Console.WriteLine("Output from labeled statement.");
//     } //main
// } //Type1
継承階層継承階層
System.Object
   System.CodeDom.CodeObject
     System.CodeDom.CodeStatement
      System.CodeDom.CodeLabeledStatement
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CodeLabeledStatement メンバ
System.CodeDom 名前空間
CodeGotoStatement クラス

CodeLabeledStatement コンストラクタ ()


CodeLabeledStatement コンストラクタ (String, CodeStatement)

ラベル名とステートメント指定して、CodeLabeledStatement クラス新しインスタンス初期化します。

名前空間: System.CodeDom
アセンブリ: System (system.dll 内)
構文構文

Public Sub New ( _
    label As String, _
    statement As CodeStatement _
)
Dim label As String
Dim statement As CodeStatement

Dim instance As New CodeLabeledStatement(label,
 statement)
public CodeLabeledStatement (
    string label,
    CodeStatement statement
)
public:
CodeLabeledStatement (
    String^ label, 
    CodeStatement^ statement
)
public CodeLabeledStatement (
    String label, 
    CodeStatement statement
)
public function CodeLabeledStatement (
    label : String, 
    statement : CodeStatement
)

パラメータ

label

ラベルの名前。

statement

ラベル関連付ける CodeStatement。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CodeLabeledStatement クラス
CodeLabeledStatement メンバ
System.CodeDom 名前空間

CodeLabeledStatement コンストラクタ (String)


CodeLabeledStatement コンストラクタ

CodeLabeledStatement クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
CodeLabeledStatement () CodeLabeledStatement クラス新しインスタンス初期化します。
CodeLabeledStatement (String) ラベル名を指定してCodeLabeledStatement クラス新しインスタンス初期化します。
CodeLabeledStatement (String, CodeStatement) ラベル名とステートメント指定してCodeLabeledStatement クラス新しインスタンス初期化します。
参照参照

関連項目

CodeLabeledStatement クラス
CodeLabeledStatement メンバ
System.CodeDom 名前空間

CodeLabeledStatement プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ EndDirectives  終了ディレクティブを含む CodeDirectiveCollection オブジェクト取得します。 ( CodeStatement から継承されます。)
パブリック プロパティ Label ラベルの名前を取得または設定します
パブリック プロパティ LinePragma  コード ステートメントのある行を取得または設定します。 ( CodeStatement から継承されます。)
パブリック プロパティ StartDirectives  開始ディレクティブを含む CodeDirectiveCollection オブジェクト取得します。 ( CodeStatement から継承されます。)
パブリック プロパティ Statement 省略可能な関連付けられているステートメント取得または設定します
パブリック プロパティ UserData  現在のオブジェクトユーザー定義可能なデータ取得または設定します。 ( CodeObject から継承されます。)
参照参照

関連項目

CodeLabeledStatement クラス
System.CodeDom 名前空間
CodeGotoStatement クラス

CodeLabeledStatement メソッド


CodeLabeledStatement メンバ

ラベル付きステートメントまたはスタンドアロンラベル表します

CodeLabeledStatement データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド CodeLabeledStatement オーバーロードされます。 CodeLabeledStatement クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ EndDirectives  終了ディレクティブを含む CodeDirectiveCollection オブジェクト取得します。(CodeStatement から継承されます。)
パブリック プロパティ Label ラベルの名前を取得または設定します
パブリック プロパティ LinePragma  コード ステートメントのある行を取得または設定します。 (CodeStatement から継承されます。)
パブリック プロパティ StartDirectives  開始ディレクティブを含む CodeDirectiveCollection オブジェクト取得します。(CodeStatement から継承されます。)
パブリック プロパティ Statement 省略可能な関連付けられているステートメント取得または設定します
パブリック プロパティ UserData  現在のオブジェクトユーザー定義可能なデータ取得または設定します。(CodeObject から継承されます。)
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

CodeLabeledStatement クラス
System.CodeDom 名前空間
CodeGotoStatement クラス


このページでは「.NET Framework クラス ライブラリ リファレンス」からCodeLabeledStatementを検索した結果を表示しています。
Weblioに収録されているすべての辞書からCodeLabeledStatementを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からCodeLabeledStatement を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「CodeLabeledStatement」の関連用語

CodeLabeledStatementのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



CodeLabeledStatementのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS