各位帮忙看看这段代码哪儿有问题,初学者,谢了...
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication检测
{
class Program
{
static void Main(string[] args)
{
//
//按键测试
//
Console.WriteLine("现在开始进行按键测试!回车键退出,其他键开始...");
Testkey();
}
private static void Testkey()
{
char ch;
int i = 0;
int conut = 0;
while (i < conut) //连续进行按键测试
{
ch = Console.ReadKey(false).KeyChar;
if (ch == '\r')
{
Console.WriteLine("你按的是回车键!");
break;
}
else if (char.IsDigit(ch))
{
Console.WriteLine("你按的是数字键!");
}
else if (char.IsLetter(ch))
{
Console.WriteLine("你按的是字母键!");
}
else if (char.IsControl(ch))
{
Console.WriteLine("你按的是控制键!");
}
else
{
Console.WriteLine("你按的是非数字键、非字母键、非控制键!");
conut = i + 1;
}
Console.WriteLine("按回车键退出,其它键继续...");
}
SortBySimple(counts);//简单选择排序
SortBySimple(counts);//冒泡排序
for (int i = 0; i < counts.Length; ++i)
{
Console.WriteLine("{0}键的次数{1}", counts.Name, counts.Count);
}
}
private static void SortBySimpleSelect(TypeCount[] counts)
{
TypeCount temp = new KeyCount();
int a = 0;
TypeCount Count = new KeyCount();
for (int i = 0; i < counts.Length - 1; ++i)
{
a = i;
for (int j = i + 1; j < counts.Length; ++j)
{
if (counts[j].Count < counts[a].Count)
{
a = j;
}
}
if (a != i)
{
KeyCount temp = counts[a];
counts[a] = counts;
counts = temp;
}
}
}
private static void SortBySimpleSelect(TypeCount[] counts)
{
TypeCount Tcount = new TypeCount();
for (int i = 0; i < counts.Length - 1; ++i)
{
for (int j = counts.Length - 2; j >= i; --j)
{
if (counts[j].Count > counts[j + 1].Count)
{
Tcount = counts[j + 1];
counts[j + 1] = counts[j];
counts[j] = Tcount;
}
}
}
}
}
}
--------------------编程问答-------------------- 什么情况 --------------------编程问答-------------------- int i = 0;
int conut = 0;
while (i < conut)
不会进循环 --------------------编程问答-------------------- while (i <= conut)试试
--------------------编程问答-------------------- 弄个断点 一步一步走吧!! --------------------编程问答-------------------- 同意楼上~~ --------------------编程问答-------------------- TypeCount[] 类的定义在哪里呀?请教楼主 --------------------编程问答-------------------- int i = 0;
int conut = 0;
while (i < conut)
0<0,一上来 就是 false, 不会进循环 --------------------编程问答--------------------
正解 +1 --------------------编程问答--------------------
int i = 0;
int conut = 0;
while (i < conut) //这三行换成 while(true)吧?
补充:.NET技术 , C#