0

我正在尝试从文件中读取一个“数字”字符串,并将其转换回整数。以下是我的代码,即 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

好的,现在这对我来说很陌生,因为我经历了许多问题和答案,并且在所有这些问题中,他们都遵循了与我使用过的类似方法,但我遇到了错误。为什么是这样?

4

1 回答 1

2

修复你看到的第一个编译错误:你需要System::在前面Int32 thresholdNum;

于 2013-08-23T18:52:57.750 回答