Why can't I declare a string in my program: “string is undeclared identifier”

前端 未结 3 1110
粉色の甜心
粉色の甜心 2021-01-12 07:12

I can\'t declare a string in my program:

string MessageBoxText = CharNameTextBox->Text;

it just doesn\'t work. It says string is u

3条回答
  •  不知归路
    2021-01-12 08:04

    Are you by any way compiling using C++/CLI, the Microsoft extension for .NET, and not standard ISO C++?

    In that case you should do the following:

    System::String^ MessageBoxText = CharNameTextBox->Text;
    

    Also see the following articles:

    • How to: Convert Between Various String Types
    • How to: Convert System::String to Standard String
    • How to: Convert Standard String to System::String

提交回复
热议问题