1

Добрый вечер, взялся за изучение C++ на Visual C++ 2010 Express. Как преобразовать из System::String^ в int? Нерабочий пример:

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
{
    int i;
    i = Convert::ToInt32(button1->Text);
    MessageBox::Show(i);
}
ixSci
  • 23,825
Alexis
  • 3,476

1 Answers1

3

Попробуйте так:

  try {
     int x = Int32::Parse(buttonX->Text);
  }
  catch (FormatException^) {
  }
stanislav
  • 34,518
  • 27
  • 98
  • 214