using System;
namespace ns{
class aa{
static void Main(string[] args){
string[] starray = new string[]{"Down the way nights are dark",
"And the sun shines daily on the mountain top",
"I took a trip on a sailing ship",
"And when I reached Jamaica",
"I made a stop"};
string aa= String.Join(".",starray);
Console.WriteLine(aa);
Console.ReadKey() ;
}
}
}
错误:
Down the way nights are dark.And the sun shines daily on the mountain top.I took a trip on a sailing ship.And when I reached Jamaica.I made a stop
Unhandled Exception: System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected from a file. Try Console.Read.
at System.Console.ReadKey(Boolean intercept)
at ns.aa.Main(String[] args)
这是因为你在 winform 程序里调用ReadKey,他无法读取键,你换成 Read() 或 ReadLine() 就行了;或者写到 控制台输出程序里
无法读取键什么意思,大佬请教,俺是小菜鸟
@xiaofang.bk:
ReadKey()函数作用:获取用户按下的下一个字符或功能键。 按下的键显示在控制台窗口中。
因为你是 winform 程序,没有一个这个窗口,所以不能输入,这就是无法读取按键的意思。
我没遇到这个bug