Reputation: 557
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
Upvotes: 4
Views: 16024
Reputation: 180874
When you say "assign result globally", do you mean using it as a class variable?
class SomeClass {
var result = general.GetInformation(int.Parse(ID), F_account, F_Info, Types);
}
In that case, you can't use var and you would have to use whatever Type GetInformation returns, for example
string result = general.GetInformation(int.Parse(ID), F_account, F_Info, Types);
or
Entity result = general.GetInformation(int.Parse(ID), F_account, F_Info, Types);
Upvotes: 3
Reputation: 65860
You can use like below:
Because your class is : Getinformation
Then
Getinformation result =null;
result = general.GetInformation(int.Parse(ID), F_account, F_Info, Types);
Upvotes: 0
Reputation: 86698
It sounds like you're trying to do var result = null;
which won't work because null
doesn't tell the compiler what type result
should be. You would need to use Sometype result = null;
.
Upvotes: 6
Reputation: 56381
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.
Upvotes: 0