Partilhar via


Languages.Item(Object) Method

Definition

Returns a Language object in the Languages collection.

public:
 EnvDTE::Language ^ Item(System::Object ^ index);
public:
 EnvDTE::Language ^ Item(Platform::Object ^ index);
EnvDTE::Language Item(winrt::Windows::Foundation::IInspectable const & index);
[System.Runtime.InteropServices.DispId(0)]
public EnvDTE.Language Item (object index);
[<System.Runtime.InteropServices.DispId(0)>]
abstract member Item : obj -> EnvDTE.Language
Public Function Item (index As Object) As Language

Parameters

index
Object

Required. The index or name of the Language object to return.

Returns

A Language object.

Attributes

Examples

The following example demonstrates how to use the Item method.

public static void Item(DTE dte)  
{  
    // Setup debug Output window.  
    Window w = (Window)dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);  
    w.Visible = true;  
    OutputWindow ow = (OutputWindow)w.Object;  
    OutputWindowPane owp = ow.OutputWindowPanes.Add("Item Method Test");  
    owp.Activate();  
    EnvDTE.Languages languages = dte.Debugger.Languages;  
    owp.OutputString("\nEdition of the environment: " + languages.DTE.Edition);  
    owp.OutputString("\nThird language in the language collection: " +   
                     languages.Item(3).Name);  
    owp.OutputString("\nThe name of the current program: " +   
                     languages.Parent.CurrentProgram.Name);  
}  
Shared Sub Item(ByRef dte As EnvDTE.DTE)  
    Dim languages As EnvDTE.Languages = dte.Debugger.Languages  
    Dim str As String = vbCrLf  
    str = "Edition of the environment: " + languages.DTE.Edition  
    str += vbCrLf + vbCrLf + "Third language in the language collection: "  
    str += languages.Item(3).Name  
    str += vbCrLf + vbCrLf + "The name of the current program: " + _  
           languages.Parent.CurrentProgram.Name  
    MessageBox.Show(str, "Language Test - Item Method")  
End Sub  

Remarks

The Item method throws a System.ArgumentException exception if the collection cannot find the object that corresponds to the index value.

Applies to