Breakpoints.Item(Object) Method

Definition

Returns a Breakpoint object in a Breakpoints collection.

[System.Runtime.InteropServices.DispId(0)]
public EnvDTE.Breakpoint Item (object index);
Parameters
index
Object

Required. The index of the Breakpoint object to return.

Returns

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.Debugger debugger = (EnvDTE.Debugger)dte.Debugger;  
    debugger.Breakpoints.Add("","Target001.cs", 13, 1, "",   
                             EnvDTE.dbgBreakpointConditionType.dbgBreakpointConditionTypeWhenTrue,   
                             "C#","", 0, "", 0, EnvDTE.dbgHitCountType.dbgHitCountTypeNone);  
    debugger.Breakpoints.Add("","Target001.cs", 15, 1, "",   
                             EnvDTE.dbgBreakpointConditionType.dbgBreakpointConditionTypeWhenTrue,   
                             "C#","", 0, "", 0, EnvDTE.dbgHitCountType.dbgHitCountTypeNone);  

    owp.OutputString("
Number of Breakpoints: " + debugger.Breakpoints.Count); owp.OutputString("
Edition of the environment: " + debugger.Breakpoints.DTE.Edition); owp.OutputString("
Parent's Current Mode: " + debugger.Breakpoints.Parent.CurrentMode); owp.OutputString("
First breakpoint is on line " + debugger.Breakpoints.Item(1).FileLine + "."); owp.OutputString("
Second breakpoint is on line " + debugger.Breakpoints.Item(2).FileLine + "."); }
Shared Sub Item(ByRef dte As EnvDTE.DTE)  
    Dim str As String  
    dte.Debugger.Breakpoints.Add("", "Target001.cs", 13, 1, "", _  
                                 EnvDTE.dbgBreakpointConditionType.dbgBreakpointConditionTypeWhenTrue, _  
                                 "C#", "", 0, "", 0, EnvDTE.dbgHitCountType.dbgHitCountTypeNone)  
    dte.Debugger.Breakpoints.Add("", "Target001.cs", 15, 1, "", _  
                                 EnvDTE.dbgBreakpointConditionType.dbgBreakpointConditionTypeWhenTrue, _  
                                 "C#", "", 0, "", 0, EnvDTE.dbgHitCountType.dbgHitCountTypeNone)  
    str = "Number of Breakpoints: " + dte.Debugger.Breakpoints.Count.ToString() + vbCrLf  
    str += "Edition of the environment: " + dte.Debugger.Breakpoints.DTE.Edition + vbCrLf  
    str += "Parent's Current Mode: " + dte.Debugger.Breakpoints.Parent.CurrentMode.ToString() + vbCrLf  
    str += "First breakpoint is on line " + dte.Debugger.Breakpoints.Item(1).FileLine.ToString() + "." + vbCrLf  
    str += "Second breakpoint is on line " + dte.Debugger.Breakpoints.Item(2).FileLine.ToString() + "." + vbCrLf  
    MessageBox.Show(str, "Item Method Test")  
End Sub  

Remarks

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

Applies to