Export (0) Print
Expand All

CodeSnippetCompileUnit Class

Represents a literal code fragment that can be compiled.

For a list of all members of this type, see CodeSnippetCompileUnit Members.

System.Object
   System.CodeDom.CodeObject
      System.CodeDom.CodeCompileUnit
         System.CodeDom.CodeSnippetCompileUnit

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

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

CodeSnippetCompileUnit can represent a literal block of code that is included directly in the source without modification.

A CodeSnippetCompileUnit stores a section of code, exactly in its original format, as a string. The CodeDOM does not translate literal code fragments. Literal code fragments are stored and output in their original format. CodeDOM objects that contain literal code are provided so developers can encapsulate code that is already in the target language.

The Value property contains the literal code fragment as a string. The LinePragma property is optional and specifies the position of the code within a source code document.

Example

[Visual Basic] 
' Creates a compile unit using a literal sring.
Dim literalCode As String
literalCode = "using System; namespace TestLiteralCode " & _
    "{ public class TestClass { public TestClass() {} } }"
Dim csu As New CodeSnippetCompileUnit(literalCode)

[C#] 
// Creates a compile unit using a literal sring;
string literalCode;
literalCode = "using System; namespace TestLiteralCode " + 
    "{ public class TestClass { public TestClass() {} } }";
CodeSnippetCompileUnit csu = new CodeSnippetCompileUnit( literalCode );            

[C++] 
// Creates a compile unit using a literal sring;
String* literalCode;
literalCode = S"using System; namespace TestLiteralCode "  
    S"{ public class TestClass { public TestClass() {} } }";
CodeSnippetCompileUnit* csu = new CodeSnippetCompileUnit( literalCode );            

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.CodeDom

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System (in System.dll)

See Also

CodeSnippetCompileUnit Members | System.CodeDom Namespace

Show:
© 2014 Microsoft