控制台读取数组[]

时间:2014-04-08 08:34:39

标签: c#

Console.WriteLine("\n\n\t\tWhat is your option?\n\n\t\t  ");
            index = int.Parse(Console.ReadLine());
            switch (index)
            {
                case 1:
                    Console.Clear();
                    System.Console.WriteLine("\n\n\tHOW MANY ID'S FOR STUDENTS\n\n\t\t");
                    ids = int.Parse(Console.ReadLine());
                    for (i=0; i < ids; i++)
                    {
                        Console.WriteLine("\n\n\tPRESS 'u' FOR U.G. students,\n\n\t'm' FOR ONLY MASTERS and\n\n\t 'p' FOR ONLY PHD STUDENTS\n\n\t\t");
                        c[i] = char.Parse(Console.ReadLine()); 
                        if (c[i] == 'u')
                        {
                            Console.Clear();
                            u[i].inputu(); //ug input
                        }

嘿伙计们,当我想阅读c [i]时,我对这部分代码有点问题,我试图使用Char.Parse(Console.Readline());但没有工作:(

1 个答案:

答案 0 :(得分:0)

试试这段代码希望它能帮上忙碌

Console.WriteLine("\n\n\t\tWhat is your option?\n\n\t\t  ");
        index = int.Parse(Console.ReadLine());
        switch (index)
        {
            case 1:
                Console.Clear();
                System.Console.WriteLine("\n\n\tHOW MANY ID'S FOR STUDENTS\n\n\t\t");
                ids = int.Parse(Console.ReadLine());
                for (i=0; i < ids; i++)
                {
                    Console.WriteLine("\n\n\tPRESS 'u' FOR U.G. students,\n\n\t'm' FOR ONLY MASTERS and\n\n\t 'p' FOR ONLY PHD STUDENTS\n\n\t\t");
                    c[i] = Convert.ToChar(Console.ReadLine()); 
                    if (c[i] == 'u')
                    {
                        Console.Clear();
                        u[i].inputu(); //ug input
                    }