I have encountered this also. My understanding is that after the first read is finished, a '\n' will remain in the input buffer. This creates a problem for the ReadLine, and results in the exception. A scheme for dealing with that is:
Code:
// p2p_question_5oct2010.cpp : main project file.
#include "stdafx.h"
using namespace System;
int main(array<System::String ^> ^args)
{
Console::WriteLine(L"Hello World");
char ch = Console::Read();
Console::WriteLine(L"The character is:{0}",ch); //Why these two things
//putting together
for(int i = 0; i<10; i++) // flush input buffer
{
if( Console::Read() == '\n')
break;
}
Console::Write(L"Enter an integer:"); //cause error???
int value = Int32::Parse(Console::ReadLine());
Console::WriteLine(L"You entered:{0}",value);
return 0;
}
This runs without the exception. See
http://www.daniweb.com/forums/thread301503.html for additional information.