win 表单应用程序字符串^ 到 int

win forms application String^ to int

本文关键字:int 字符串 表单 应用程序 win      更新时间:2023-10-16

我正在使用带有C++的Windows表单应用程序。

我想将String^转换为int

我的代码是:

int number = std::stoi(TextBox1->Text);

但错误显示:

no instance of overloaded function "std::stoi" matches the argument list argument types are :(System:: String ^)

^String面前意味着什么?

试试这个:

int number = std::stoi(std::wstring(TextBox1->Text->Data()));