访问绑定DataGridView中访问单元格值的最快方法

时间:2013-02-07 14:21:51

标签: c# winforms performance datagridview

我有一个DataGridView绑定到对象的BindingList,我需要尽快访问每行中特定单元格的值。这样做会更快:

if (((ObjectType)row.DataBoundItem).StringProperty != string.Empty)
{
}

...或...

if (row.Cells["STRINGPROPERTY"].Value != string.Empty)
{
}

还是有另一种方式比这两种方式都快吗?

1 个答案:

答案 0 :(得分:1)

如果为空 null ,有很多方法可以检查值,但是从您的主要问题开始,您可以尝试Benchmarking method calls in C#

  1. String.IsNullOrEmpty
  2. String.IsNullOrWhiteSpace
  3. Best way to check if column returns a null value (from database to .net application)
相关问题