CodeLabeledStatement 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
레이블이 지정된 문 또는 독립 실행형 레이블을 나타냅니다.
public ref class CodeLabeledStatement : System::CodeDom::CodeStatement
public class CodeLabeledStatement : System.CodeDom.CodeStatement
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeLabeledStatement : System.CodeDom.CodeStatement
type CodeLabeledStatement = class
inherit CodeStatement
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeLabeledStatement = class
inherit CodeStatement
Public Class CodeLabeledStatement
Inherits CodeStatement
- 상속
- 특성
예제
다음 예제 코드에서는 프로그램 흐름을 리디렉션하는 데 a CodeGotoStatement 와 a CodeLabeledStatement 를 사용하는 방법을 보여 줍니다.
// 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.
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
설명
CodeLabeledStatement 는 레이블을 나타내고 필요에 따라 연결된 문을 나타냅니다. 레이블을 사용하여 대상 CodeGotoStatement을 나타낼 수 있습니다.
Statement 속성은 선택 사항입니다. 레이블만 만들려면 속성을 초기화되지 않은 상태로 둡 Statement 니다.
메모
모든 언어가 문과 레이블을 지원하는 goto 것은 아니므로 코드 생성기가 플래그를 사용하여 메서드 GotoStatements 를 호출 Supports 하여 문과 레이블을 지원하는 goto 지 테스트해야 합니다.
생성자
| Name | Description |
|---|---|
| CodeLabeledStatement() |
CodeLabeledStatement 클래스의 새 인스턴스를 초기화합니다. |
| CodeLabeledStatement(String, CodeStatement) |
지정된 레이블 이름 및 문을 사용하여 클래스의 CodeLabeledStatement 새 인스턴스를 초기화합니다. |
| CodeLabeledStatement(String) |
지정된 레이블 이름을 사용하여 클래스의 CodeLabeledStatement 새 인스턴스를 초기화합니다. |
속성
| Name | Description |
|---|---|
| EndDirectives |
CodeDirectiveCollection 끝 지시문을 포함하는 개체를 가져옵니다. (다음에서 상속됨 CodeStatement) |
| Label |
레이블의 이름을 가져오거나 설정합니다. |
| LinePragma |
코드 문이 발생하는 줄을 가져오거나 설정합니다. (다음에서 상속됨 CodeStatement) |
| StartDirectives |
CodeDirectiveCollection 시작 지시문을 포함하는 개체를 가져옵니다. (다음에서 상속됨 CodeStatement) |
| Statement |
선택적 연결된 문을 가져오거나 설정합니다. |
| UserData |
현재 개체에 대한 사용자 정의 데이터를 가져옵니다. (다음에서 상속됨 CodeObject) |
메서드
| Name | Description |
|---|---|
| Equals(Object) |
지정된 개체가 현재 개체와 같은지 여부를 확인합니다. (다음에서 상속됨 Object) |
| GetHashCode() |
기본 해시 함수로 사용됩니다. (다음에서 상속됨 Object) |
| GetType() |
현재 인스턴스의 Type 가져옵니다. (다음에서 상속됨 Object) |
| MemberwiseClone() |
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| ToString() |
현재 개체를 나타내는 문자열을 반환합니다. (다음에서 상속됨 Object) |