无法分配使用 asp.net 隐式类型局部变量
我有
var result = general.GetInformation(int.Parse(ID), F_account, F_Info, Types);
这个 GetInformation 是我的 Entity.Getinformation 类..当我尝试全局分配结果时,我得到 Cannot allocate to隐式类型局部变量?
var result = ?
我应该在全局中分配什么?
谢谢
I have this
var result = general.GetInformation(int.Parse(ID), F_account, F_Info, Types);
this GetInformation is my Entity.Getinformation class.. when I am trying to assign result globly I am getting Cannot Assign to implicit typed local variable?
var result = ?
what should I assign in global?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
听起来您正在尝试执行
var result = null;
,但这是行不通的,因为null
不会告诉编译器result
的类型> 应该是。您需要使用Sometype result = null;
。It sounds like you're trying to do
var result = null;
which won't work becausenull
doesn't tell the compiler what typeresult
should be. You would need to useSometype result = null;
.当您说“全局分配结果”时,您的意思是使用它作为类变量吗?
在这种情况下,您不能使用 var 并且您必须使用 Type GetInformation 返回的任何内容,例如
或
When you say "assign result globally", do you mean using it as a class variable?
In that case, you can't use var and you would have to use whatever Type GetInformation returns, for example
or
您的错误是否类似于“无法将方法组分配给隐式类型的局部变量”?
另外,
GetInformation
是否是一个类?如果这两个正确,问题在于您正在尝试对方法名称使用隐式类型,而
var
不允许这样做。Is your error something like "Cannot assign method group to an implicitly-typed local variable"?
Also, is
GetInformation
by any chance a class?If those two are correct, the problem is that you are trying to use implicit typing against a method name, something
var
isn't allowed to do.您可以像下面这样使用:
因为您的类是:Getinformation
然后
You can use like below:
Because your class is : Getinformation
Then