1

Line below in my VS and works fine I checked in and my colleague get these code piece..

vm.MuayeneId = (MuayeneId ?? SessionItems.AktifMuayene?.MuayeneId) ?? throw new Exception("Muayene Id bulunamadi");

Somehow in his Visual Studio compiler draw the red line under throw keyword and says "; expected". Next line of these code yellow line and says "Unreachable code.." This is how it looks; enter image description here

My colleague has also .NET 4.6.2 installed in his PC.. so what may cause this?

TyForHelpDude
  • 4,828
  • 10
  • 48
  • 96

1 Answers1

4

The syntax is called throw expressions and it was introduced by C# 7.0. I assume your colleques use C# 6.0 or below hence the code does not compile.

Maybe your colleques are able to upgrade Visual Studio to use C# 7.0, see https://stackoverflow.com/a/43048660/3936440

C# version history can be found here posted by John Skeet. According to his list C# 7.0 was released with .NET 4.7 and VS 2017 (March 2017).

ViRuSTriNiTy
  • 5,017
  • 2
  • 32
  • 58