我想检索所有数字(因为列中还有其他内容像“N/A”等)在我的列中DataGridView
并将它们写入List<int>
。从DataGridView的列中提取所有数字,并写入一个int列表
一些伪代码:
List<int> data = new List<int>();
foreach (string s from column 3 in DataGridView)
{
Check if s can be converted into a number;
data.Add(Convert.ToInt32(s));
}
您可以使用'Int32.TryParse'而不是'Convert.ToInt32'。 –