用foreach遍历 datagridView 指定列所有的内容

string s = "";
foreach (DataGridViewRow item in dataGridView1.Rows) {
    s += item.Cells["单词"].FormattedValue + "\n";
}
MessageBox.Show(s);



为什么不用for呢 因foreach快


string s = "";
for (int i = 0; i < dataGridView1.Rows.Count; i++) {
    s += dataGridView1.Rows[i].Cells["单词"].FormattedValue + "\n";
}
MessageBox.Show(s);

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-27
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-06
  • 2021-05-16
  • 2022-12-23
  • 2021-12-04
相关资源
相似解决方案