Cannot implicitly convert type 'string' to 'int' error

后端 未结 3 901
梦谈多话
梦谈多话 2021-01-28 05:33
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Assignment2
{
class Program
{
    static void Main(string[] args)
    {
         


        
3条回答
  •  半阙折子戏
    2021-01-28 05:48

    The offending code are your case statements. a is an int. Your case statements all use strings. Simply remove the quotes around the numbers:

    switch(a)
    {
        case 1: 
                // some code
                break;
        case 2: 
                // some code
                break;
        // rest of cases
    }
    

提交回复
热议问题