在C#开发中,有时在使用C#方法或者属性时,往往有时候会把一个C#函数当做类的属性来用,这个时候就会报类似如下的错误:
Severity Code Description Project File Line Suppression State
Error CS0019 Operator '>' cannot be applied to operands of type 'method group' and 'int' XfExpress.XFA6.Contract.Quote D:\Program Files\VisualStudio\Project1\TPYYES\XfExpress\XfExpress.TPYYES.Contract.Quote\FrmSimpleOfferManager.cs 164 Active
具体的错误如图所示:
此时,因为DataRow的“Count”是一个C#方法函数,而我们把它当属性来使用了,因此就会报“Severity Code Description Project File Line Suppression State”错误。
解决方案:
将“rows.Count”改成“rows.Count()”即可!