简体   繁体   中英

I'm trying to run a loop, and I'm getting an error which I don't know how to fix

Beginner here in c# using Visual Studio. I've been trying to run a loop, but it keeps giving me Warning MSB3026 . I'm not sure why, here's the code,

Console.WriteLine("Would you like to play: Y/N");
do
{
    if (Console.ReadLine() == "y")
    {
        Console.WriteLine("Good");
    }
} while (Console.ReadLine() == "N");
            

I've had a similar issue before, and usually, I just use task manager and close visual studio to eliminate any background tasks that are getting in the way of what I'm trying to do. However, in this case, no background tasks are running. I was wondering how to fix the warning, and how to get the code to work.

If I'm correct its an issue with one version of Visual studio (correct me if I'm wrong).

The code is totally okay, and it works for me flawlessly. You can either update visual studio to 2017 and higher or you can try disabling the warning (it won't fix the code if it's not running tho).

To disable warning use #pragma warning disable 3026

To restore warning use #pragma warning restore 3026

Nothing wrong with your code. Try updating VS. To update VS click Help at top of screen and select "Check for Updates"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM