0

I have encounter a problem that i dont know why it happens,

My code check For response of Jtoken and then if it does exist it will add to the list of errors

if (response.Response is JToken jToken)
{
     List<ExceptionDescriptor> exceptions = jToken.ToObject<List<ExceptionDescriptor>>();
     GlobalErrorCatcher.CatchException(exceptions);
}

my issue is that at first when i build the project it failed with out showing any error message, after looking at this question and by changing the error message form Build and IntelliSense to Build only i can see 3 errors on line 57 which it is if (response.Response is JToken jToken) the errors are

) expected
; expected
} expected

when i change my code to

JToken jToken = response.Response as JToken;
if (jToken != null)
{

    List<ExceptionDescriptor> exceptions = jToken.ToObject<List<ExceptionDescriptor>>();
                GlobalErrorCatcher.CatchException(exceptions);
}

i do not encounter this issue, My application Target Framework is .NET Framework 4.6.1 what am i doing wrong does .NET not like is operation ??

P.s: this issue does not come up on any other computer

Reza Del
  • 763
  • 10
  • 30

1 Answers1

3

That syntax is a C# 7.1 feature, which is very, very new. The computer it’s failing on probably does not have the latest Visual Studio (or whatever other compiler your using) installed, so it doesn’t understand that new syntax.