Cannot implicitly convert type string to int

前端 未结 4 1253
囚心锁ツ
囚心锁ツ 2020-12-21 16:34
    Console.WriteLine (\"Please enter some numbers\");
        int sum = 0;
        for(;;)
        {
            string input = Console.ReadLine ();
            if          


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-21 17:22

    to check if the input of the user is right i would prefer

    int userInput = 0;
    if( int.TryParse( input, out userInput ) == false )
    {
         break;
    }
    

    This is just an advise and not directly a solution to your problem. There are enough answers =)

提交回复
热议问题