我正在尝试从文件中读取一个字符串'Number',然后将其转换回整数。以下是我的代码,即C ++ / CLI
int InformationReader::getThreshold()
{
StreamReader ^reader = gcnew StreamReader("threshold.dat");
System::String ^thresholdStr = reader->ReadLine();
Int32 thresholdNum;
boolean a = Int32::TryParse(thresholdStr,thresholdNum);
return 0;
}
但是,只要执行此代码,我就会收到以下错误
1>InformationReader.cpp(29): error C2065: 'Int32' : undeclared identifier
1>InformationReader.cpp(29): error C2146: syntax error : missing ';' before identifier 'thresholdNum'
1>InformationReader.cpp(29): error C2065: 'thresholdNum' : undeclared identifier
1>InformationReader.cpp(31): error C2065: 'boolean' : undeclared identifier
1>InformationReader.cpp(31): error C2146: syntax error : missing ';' before identifier 'a'
1>InformationReader.cpp(31): error C2065: 'a' : undeclared identifier
1>InformationReader.cpp(31): error C2653: 'Int32' : is not a class or namespace name
1>InformationReader.cpp(31): error C2065: 'thresholdNum' : undeclared identifier
1>InformationReader.cpp(31): error C3861: 'TryParse': identifier not found
好了,现在这对我来说很陌生,因为我经历了一些问题和答案,并且在所有这些问题和答案中,他们都遵循了我所使用的类似方法,但我收到了错误。为什么是这样?
答案 0 :(得分:2)
修复您看到的第一个编译错误:System::
Int32 thresholdNum;