CodeSnippetStatement CodeSnippetStatement CodeSnippetStatement CodeSnippetStatement Class

定義

表示使用常值 (Literal) 程式碼片段的陳述式。Represents a statement using a literal code fragment.

public ref class CodeSnippetStatement : System::CodeDom::CodeStatement
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Serializable]
public class CodeSnippetStatement : System.CodeDom.CodeStatement
type CodeSnippetStatement = class
    inherit CodeStatement
Public Class CodeSnippetStatement
Inherits CodeStatement
繼承
CodeSnippetStatementCodeSnippetStatementCodeSnippetStatementCodeSnippetStatement
屬性

範例

下列範例會使用常值程式碼片段CodeSnippetStatement來建立類別的實例。The following example creates an instance of the CodeSnippetStatement class using a literal code fragment. 這個程式碼範例是針對CodeRegionDirective類別提供之較大範例的一部分。This code example is part of a larger example provided for the CodeRegionDirective class.

CodeSnippetStatement snippet1 = new CodeSnippetStatement();
snippet1.Value = "            Console.WriteLine(field1);";

CodeRegionDirective regionStart = new CodeRegionDirective(CodeRegionMode.End, "");
regionStart.RegionText = "Snippet Region";
regionStart.RegionMode = CodeRegionMode.Start;
snippet1.StartDirectives.Add(regionStart);
snippet1.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, string.Empty));
Dim snippet1 As New CodeSnippetStatement()
snippet1.Value = "            Console.WriteLine(field1)"

Dim regionStart As New CodeRegionDirective(CodeRegionMode.End, "")
regionStart.RegionText = "Snippet Region"
regionStart.RegionMode = CodeRegionMode.Start
snippet1.StartDirectives.Add(regionStart)
snippet1.EndDirectives.Add(New CodeRegionDirective(CodeRegionMode.End, String.Empty))

備註

CodeSnippetStatement可以代表使用常值程式碼片段的語句, 而不需修改就能直接包含在來源中。CodeSnippetStatement can represent a statement using a literal code fragment that will be included directly in the source without modification.

會以字串的形式, 將區段的程式碼完全以其原始格式儲存。CodeSnippetStatementA CodeSnippetStatement stores a section of code exactly in its original format as a string. CodeDOM 不會轉譯常值程式碼片段。The CodeDOM does not translate literal code fragments. 常值程式碼片段會以其原始格式儲存和輸出。Literal code fragments are stored and output in their original format. 系統會提供包含常值程式碼的 CodeDOM 物件, 讓開發人員可以封裝已在目的語言中的程式碼。CodeDOM objects that contain literal code are provided so developers can encapsulate code that is already in the target language.

Value屬性包含程式碼片段語句的常值程式碼。The Value property contains the literal code for the snippet statement.

建構函式

CodeSnippetStatement() CodeSnippetStatement() CodeSnippetStatement() CodeSnippetStatement()

初始化 CodeSnippetStatement 類別的新執行個體。Initializes a new instance of the CodeSnippetStatement class.

CodeSnippetStatement(String) CodeSnippetStatement(String) CodeSnippetStatement(String) CodeSnippetStatement(String)

使用指定的程式碼片段,初始化 CodeSnippetStatement 類別的新執行個體。Initializes a new instance of the CodeSnippetStatement class using the specified code fragment.

屬性

EndDirectives EndDirectives EndDirectives EndDirectives

取得包含結尾指示詞的 CodeDirectiveCollection 物件。Gets a CodeDirectiveCollection object that contains end directives.

(Inherited from CodeStatement)
LinePragma LinePragma LinePragma LinePragma

取得或設定程式碼陳述式發生所在的行。Gets or sets the line on which the code statement occurs.

(Inherited from CodeStatement)
StartDirectives StartDirectives StartDirectives StartDirectives

取得包含開頭指示詞的 CodeDirectiveCollection 物件。Gets a CodeDirectiveCollection object that contains start directives.

(Inherited from CodeStatement)
UserData UserData UserData UserData

取得目前物件的使用者可定義資料。Gets the user-definable data for the current object.

(Inherited from CodeObject)
Value Value Value Value

取得或設定常值程式碼片段陳述式。Gets or sets the literal code fragment statement.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

適用於