cannot implicitly convert type 'Microsoft.SolverFoundation.Services.Term' to 'bool'

StackOverflow https://stackoverflow.com/questions/12529234

  •  03-07-2021
  •  | 
  •  

문제

I got an exception "cannot implicitly convert type 'Microsoft.SolverFoundation.Services.Term' to 'bool'" at the code below, how should I solve it?

Term a=null;
            if(a==null)//<--this line exception
            {

            }

Below is the snap shot

enter image description here

도움이 되었습니까?

해결책

The problem is that the Term class overrides the equality operator in a way that it doesn't return bool but another Term instead: http://msdn.microsoft.com/en-us/library/ff525374%28v=vs.93%29.aspx

I am not sure why they would do something like this, because it goes against any advice on overriding operators...

To fix your problem, use this code instead:

if(ReferenceEquals(a, null))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top