属性或索引器不能作为 out 或 ref 参数传递 [英] A property or indexer may not be passed as an out or ref parameter

查看:33
本文介绍了属性或索引器不能作为 out 或 ref 参数传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到上述错误,但无法解决.我用谷歌搜索了一下,但无法摆脱它.

I'm getting the above error and unable to resolve it. I googled a bit but can't get rid of it.

我有 BudgetAllocate 类,它的属性是 budget,它是 double 类型.

I have class BudgetAllocate whose property is budget which is of double type.

在我的dataAccessLayer中,

在我的一堂课中,我正在尝试这样做:

In one of my classes I am trying to do this:

double.TryParse(objReader[i].ToString(), out bd.Budget);

引发此错误的原因:

属性或索引器不能作为 out 或 ref 参数在编译时间.

Property or indexer may not be passed as an out or ref parameter at compile time.

我什至试过这个:

double.TryParse(objReader[i].ToString().Equals(DBNull.Value) ? "" : objReader[i].ToString(), out bd.Budget);

其他一切正常,层之间的引用存在.

Everything else is working fine and references between layers are present.

推荐答案

你不能使用

double.TryParse(objReader[i].ToString(), out bd.Budget); 

用一些变量替换 bd.Budget.

replace bd.Budget with some variable.

double k;
double.TryParse(objReader[i].ToString(), out k); 

这篇关于属性或索引器不能作为 out 或 ref 参数传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆