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

I have it

var result = general.GetInformation(int.Parse(ID), F_account, F_Info, Types); 

this GetInformation is my Entity.Getinformation class .. when I try to assign the result globly, I get Can not Assign for an implicit typed local variable?

 var result = ? 

What should I assign globally?

thanks

+4
source share
4 answers

When you say "assign the 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 this case, you cannot use var , and you will need to use the GetInformation return type, 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); 
+3
source

It looks like you are trying to do var result = null; which will not work because null does not tell the compiler what type of result should be. You will need to use Sometype result = null; .

+6
source

Is your error something like "Cannot assign an implicitly typed local variable to a group of methods"?

Also, is there a GetInformation randomly class?

If these two are correct, the problem is that you are trying to use implicit typing for the method name, something var not allowed to do.

0
source

You can use as below:

Since your class : Getinformation

Then

 Getinformation result =null; result = general.GetInformation(int.Parse(ID), F_account, F_Info, Types); 
0
source

Source: https://habr.com/ru/post/1313136/


All Articles