Export (0) Print
Expand All

Expressions.Item Method

Returns a Expression object in a Expressions collection.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Expression Item(
	Object index
)

Parameters

index
Type: System.Object

Required. The index of the Expression object to return.

Return Value

Type: EnvDTE.Expression
An Expression object.

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

The following example demonstrates how to use the Item method.

To test this method:

  1. The target application must contain a class A. The function Main must create an instance of a class A called "a".

  2. Set a breakpoint in the function Main after an instance of class A is created and its member variables are initialized.

  3. Run the target application in the debug mode.

  4. When the application stops at the breakpoint, run the add-in.

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.Expression exp = dte.Debugger.GetExpression("a", true, 1);
    EnvDTE.Expressions exps = exp.DataMembers;
    owp.OutputString("\nExpression count: " + exps.Count);
    owp.OutputString("\nEdition of the environment: " + exps.DTE.Edition);
    owp.OutputString("\nThe name of the current program: " + 
                     exps.Parent.CurrentProgram.Name);
    owp.OutputString("\nSecond expression: " + exps.Item(2).Name);
}

Show:
© 2014 Microsoft