我有以下几种方法:
public int CountProperty1
{
get
{
int count = 0;
foreach (var row in Data)
{
count = count + row.Property1;
}
return count ;
}
}
public int CountProperty2
{
get
{
int count = 0;
foreach (var row in Data)
{
count = count + row.Property2;
}
return count ;
}
}
在这里避免重复并尽可能共享代码的最佳方法是什么?