This documentation is archived and is not being maintained.

CodeSnippetCompileUnit Class

Represents a literal code fragment that can be compiled.

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


[Visual Basic]
Public Class CodeSnippetCompileUnit
   Inherits CodeCompileUnit
public class CodeSnippetCompileUnit : CodeCompileUnit
public __gc class CodeSnippetCompileUnit : public
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.


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.


[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)

// 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 );            

// 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.


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