Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Function Element (IntelliSense Code Snippets) 

Specifies a function to execute when the literal or object receives focus in Visual Studio.


<Function>
    FunctionName
</Function>

The following sections describe attributes, child elements, and parent elements.

Attributes

None.

Child Elements

None.

Parent Elements

Element Description

Literal

Defines the literal fields of the code snippet that you can edit.

Object

Defines the object fields of the code snippet that you can edit.

A text value is required.

This text specifies a function to execute when the literal or object field receives focus in Visual Studio.

The Function element is only supported in Visual C# and Visual J# code snippets. For a complete list of supported functions, see Code Snippet Functions.

The following code example shows an example of the GenerateSwitchCases function. This function generates a case statement for each value in the enumeration specified in $expression$.

<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <!-- Insert Header information here. -->
        </Header>
        <Snippet>
            <Declarations>
                <Literal>
                    <ID>expression</ID>
                    <ToolTip>Expression to switch on.</ToolTip>
                    <Default>switch_on</Default>
                </Literal>
                <Literal Editable="false">
                    <ID>cases</ID>
                    <Function>GenerateSwitchCases($expression$)</Function>
                    <Default>default:</Default>
                </Literal>
            </Declarations>
            <Code Language="CSharp">
                <![CDATA[
                    switch ($expression$)
                    {
                         $cases$
                    }
                ]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft