codeReference
A codeReference element is used to insert a commonly used code snippet into a conceptual topic. The code snippets are stored in an external file.
Usage
To use a code reference, simply insert its ID as the inner text of a codeReference element anywhere within a topic. You can combine multiple snippets with a common example ID into one code reference by specifying their sample IDs as a comma-separated list after the hash character.
Example
This example uses the samples from the example file in the Code Snippets File topic. The first three are the individual snippets. The last one combines the "create instance" snippets into one example.
Define a class
<codeReference>ClassDefinition#Define</codeReference>
Create a local instance
<codeReference>CreateInstance#Local</codeReference>
Create a static (shared) instance
<codeReference>CreateInstance#Static</codeReference>
An example of combining snippets with a common example ID
<codeReference>CreateInstance#Local,Static</codeReference>Example Output
Define a class
public class CSharpClass()
{
// Members go here
}Public Class VBClass
' Members go here
End ClassNo code example is currently available or this language may not be supported.No code example is currently available or this language may not be supported.Create a local instance
CSharpClass x = new CSharpClass();Dim x As VBClass = New VBClass()No code example is currently available or this language may not be supported.No code example is currently available or this language may not be supported.Create a static (shared) instance
public static CSharpClass sharedInstance = new CSharpClass();Public Shared sharedInstance As VBClass = New VBClass()No code example is currently available or this language may not be supported.No code example is currently available or this language may not be supported.An example of combining snippets with a common example ID
CSharpClass x = new CSharpClass();
...
public static CSharpClass sharedInstance = new CSharpClass();Dim x As VBClass = New VBClass()
...
Public Shared sharedInstance As VBClass = New VBClass()No code example is currently available or this language may not be supported.No code example is currently available or this language may not be supported.