C# Unreachable code detected

后端 未结 5 2606
抹茶落季
抹茶落季 2021-02-20 18:57

I\'m getting a \"Unreachable code detected\" message in Visual Studio at the point i++ in my code below. Can you spot what I\'ve done wrong?

try
{
    RegistryKe         


        
5条回答
  •  北荒
    北荒 (楼主)
    2021-02-20 19:25

    You can also end up getting unreachable code if you use say for example Entity Framework, and you didn't add that reference to that project.

    Say you have several projects like A Data Layer Project, a Domain Classes, then you create a console app for testing or whatever and you reference where your dbcontext is at, but if you don't use say nuget and add in EF, you will get code unreachable when trying to write a loop etc...

提交回复
热议问题