黑色毛衣
小水手

UID 30139
精华
0
积分 4
帖子 4
阅读权限 10
注册 2007-5-25
状态 离线
|
编译环境:.net2005 托管代码
用的是try...catch()
测试正常!
#include "stdafx.h"
#using <System.dll>
using namespace System;
int _tmain(int argc, _TCHAR* argv[])
{
String^ str = gcnew String("");
str = Console::ReadLine();
try
{
int a = Convert::ToInt32(str);
}
catch(...)
{
Console::WriteLine("Not Int32");
return -1;
}
Console::WriteLine(str);
return 0;
}
|
|