だから私は情報を含むデータグリッドを持っているwinformを持っていて、それを検索したいのですが、検索の基準を製品の年(int)とそのタイプ(文字列)にしたいのです。
products[] a = new products[productscopy.Count];
int type = int.Parse(textBox2.Text);
int year = int.Parse(textBox1.Text);
int br = 0;
foreach (products sl in productscopy)
{
if (sl.Year == year && sl.Type == type) //line that causes problem
{
a[br] = sl; br++;
}
}
if (br > 0)
{
products[] b = new products[br];
for (int i = 0; i < br; i++)
{
b[i] = a[i];
}
dataGridView1.DataSource = b;
dataGridView1[0, 0].Selected = false;
}
else { dataGridView1.DataSource = null; }