I'm having a problem this evening, where I don't understand why I cannot add a list to the watch window.
The problem is occurring with the following minimum reproducible example.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Text;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace demo
{
public partial class formParts : Form
{
List<part> parts = new List<part>();
List<part> partChanges = new List<part>();
List<part> searchInputs = new List<part>();
public formParts()
{
InitializeComponent();
searchInputs.Add(new part());
// ...
}
// ...
private void button2_Click(object sender, EventArgs e)
{
partAccess db = new partAccess();
if (searchInputs[0].id == 0)
{
parts = db.getParts();
}
else
{
parts = db.getPart(searchInputs[0].id);
}
refreshResultsTable();
}
// ...
}
}
If I set a breakpoint for example on parts = db.getParts();
then I can add parts
to the watch window, and after stepping over this line, can see parts
populated with hundreds of entries that have been pulled from an SQL database. If I then continue the application and pause, I cannot see the list contents. Equally, if I don't add this breakpoint, when I add parts
to the watch window, watch gives me this error:
parts error CS0103: The name 'parts' does not exist in the current context