Compartilhar via


CodeModel.Language Property

Definition

Gets the programming language used to author the code.

public:
 property System::String ^ Language { System::String ^ get(); };
public:
 property Platform::String ^ Language { Platform::String ^ get(); };
[System.Runtime.InteropServices.DispId(3)]
public string Language { [System.Runtime.InteropServices.DispId(3)] get; }
[<System.Runtime.InteropServices.DispId(3)>]
[<get: System.Runtime.InteropServices.DispId(3)>]
member this.Language : string
Public ReadOnly Property Language As String

Property Value

A CodeModelLanguageConstants constant.

Attributes

Examples

Sub LanguageExample(ByVal dte As DTE2)  

    ' Before running this example, open a solution that contains   
    ' one or more projects.  
    Dim langs As String  
    Dim proj As Project  
    For Each proj In dte.Solution  
        Try  
            Dim cm As CodeModel = proj.CodeModel  
            langs &= proj.Name & "'s language is "  

            Select Case cm.Language  
                Case CodeModelLanguageConstants.vsCMLanguageMC, _  
                    CodeModelLanguageConstants.vsCMLanguageVC  
                    langs &= "C++" & vbCrLf  
                Case CodeModelLanguageConstants.vsCMLanguageCSharp  
                    langs &= "C#" & vbCrLf  
                Case CodeModelLanguageConstants.vsCMLanguageVB  
                    langs &= "Visual Basic" & vbCrLf  
                Case "{E6FDF8BF-F3D1-11D4-8576-0002A516ECE8}"  
                    langs &= "J#" & vbCrLf  
            End Select  
        Catch  
        End Try  
    Next  

    MsgBox(langs)  

End Sub  
public void LanguageExample(DTE2 dte)  
{  
    // Before running this example, open a solution that contains one   
    // or more projects.  
    string langs = "";  
    foreach (Project proj in dte.Solution)  
    {  
        try  
        {  
            CodeModel cm = proj.CodeModel;  
            langs += proj.Name + "'s language is ";  

            switch (cm.Language)  
            {  
                case CodeModelLanguageConstants.vsCMLanguageMC:  
                case CodeModelLanguageConstants.vsCMLanguageVC:  
                    langs += "C++" + Environment.NewLine;  
                    break;  
                case CodeModelLanguageConstants.vsCMLanguageCSharp:  
                    langs += "C#" + Environment.NewLine;  
                    break;  
                case CodeModelLanguageConstants.vsCMLanguageVB:  
                    langs += "Visual Basic" + Environment.NewLine;  
                    break;  
                case "{E6FDF8BF-F3D1-11D4-8576-0002A516ECE8}":  
                    langs += "J#" + Environment.NewLine;  
                    break;  
            }  
        }  
        catch  
        {  
        }  
    }  

    MessageBox.Show(langs);  
}  

Remarks

Note

The values of code model elements such as classes, structs, functions, attributes, delegates, and so forth can be non-deterministic after making certain kinds of edits, meaning that their values cannot be relied upon to always remain the same. For more information, see the section Code Model Element Values Can Change in Discovering Code by Using the Code Model (Visual Basic).

Applies to