I am trying to read a string which is a 'Number' from a file, and convert it back to an integer. Following is my code, which is 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;
}
But, as soon as this code get executed, I get the following error
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
OK now this is alien to me, because I went through number of questions and answers, and in all of them they have followed the similar approach as I have used but I am getting an error. Why is this?
Fix the first compilation error you see: You need a System::
in front of the Int32 thresholdNum;