标题:语句错误CS0136
取消只看楼主
馨欣
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2008-10-26
结帖率:100%
 问题点数:0 回复次数:1 
语句错误CS0136
//程序清单P5_2.cs:
using System;
namespace P5_2
{
    class WhileCycleSample
    {
         static void Main()
         {
               Console.WriteLine("请输入1~5之间的一个分数(按X键退出):");
               char ch = Console.ReadKey().KeyChar;
               while (ch != 'x' && ch != 'x')
               {
                     switch (ch)
                     {
                           case '5':
                                Console.WriteLine("优秀");
                                break;
                           case '4':
                                Console.WriteLine("良好");
                                break;
                           case '3':
                                Console.WriteLine("及格");
                                break;
                           case '2':
                                Console.WriteLine("不及格");
                                break;
                           case '1':
                                Console.WriteLine("不及格");
                                break;
                            default:
                                Console.WriteLine("请输入1~5之间的整数");
                                break;
                       }
                Console.WriteLine("请输入分数(按X键退出):");
                char ch = Console.ReadKey().KeyChar;
                }
          }
    }
}

语句错误CS0136:不能在此范围内声明名为“ch”的局部变量,因为这样会使“ch”具有不同的含义,而它已在“父级或当前”范围总表示其他内容了。

请问这个问题怎么解决??
 char ch = Console.ReadKey().KeyChar;此语句是什么意思??

谢谢!!
搜索更多相关主题的帖子: 语句 
2008-10-26 13:00
馨欣
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2008-10-26
得分:0 
OK!That's right! Thank you!
2008-10-26 13:42



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-240670-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.236898 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved