그래서 나는 그것에있는 정보가있는 DataGrid가 있고 그것을 검색하고 싶습니다 그러나 검색 조건을 Year (int)과 해당 유형 (문자열).운영자 == 문자열 및 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; }
'sl.Year' 및'sl.Type' 유형은 무엇입니까? BTW - 오타가 있습니다. 'sl.Year == year', 두 개의'= '기호, 하나가 아닌 부호 여야합니다. – Oded
sl.Year = 년? 당신이 원한다면 : sl.Year == year – Gisway
'(sl.Year = year'는 거의 확실한 버그입니다.)'=='no' =''를 원할 것입니다. – Servy