示例:
do{
byte.TryParse(Console.ReadLine(),outoption);
if(option==1){
write(path);
}elseif(option==2){
read(path);
}else
Console.WriteLine("Wrongoption");
}while(option!=1||option!=2);
if(option==1){
write(path);
break;
}elseif(option==2){
read(path);
break;
}else
扩展资料
C#在WinForm中打开控制台显示
例:
namespace测试使用
{
publicpartialclassForm1:Form
{
[System.Runtime.InteropServices.DllImport("kernel32.dll",SetLastError=true)]
[return:System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
staticexternboolAllocConsole();
[System.Runtime.InteropServices.DllImport("Kernel32")]
publicstaticexternvoidFreeConsole();
publicForm1()
{
InitializeComponent();
}
privatevoidForm1_Load(objectsender,EventArgse)
{
AllocConsole();//开启控制台
}
}
}