Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot assign <null> to implicit types local variable using asp.net

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

like image 897
user354625 Avatar asked Jan 22 '23 21:01

user354625


2 Answers

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;.

like image 116
Gabe Avatar answered Jan 24 '23 12:01

Gabe


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);
like image 22
Michael Stum Avatar answered Jan 24 '23 13:01

Michael Stum