String 转换文本框->;文本到字符串

String 转换文本框->;文本到字符串,string,text,textbox,c++-cli,String,Text,Textbox,C++ Cli,嘿,我正在尝试将文本框中输入的文本保存为字符串 #pragma once #include <iostream> #include <string> namespace Project1 { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System:

嘿,我正在尝试将文本框中输入的文本保存为字符串

#pragma once
#include <iostream>
#include <string>

namespace Project1 {

    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;


    int IloscBD1=0, IloscBD2=0, IloscPD1, IloscPD2, Suma, I, J, Punkty, P1, P2, P3, P4, P5, P6, Druzyna;
    int TabPunkt[10][6];

    std::string TabOdpowiedzi[10][6];

...


...
private: System::Void buttonZ_Click(System::Object^  sender, System::EventArgs^  e) {
    TabOdpowiedzi[1][1] = (Convert::ToString(textPO->Text));
    this->textPN->Text = (Convert::ToString(TabOdpowiedzi[1][1]));
}
#pragma一次
#包括
#包括
命名空间项目1{
使用名称空间系统;
使用名称空间System::ComponentModel;
使用名称空间系统::集合;
使用命名空间System::Windows::Forms;
使用名称空间System::Data;
使用名称空间系统::绘图;
int IloscBD1=0,IloscBD2=0,IloscPD1,IloscPD2,Suma,I,J,Punkty,P1,P2,P3,P4,P5,P6,Druzyna;
int TabPunkt[10][6];
std::string TabOdpowiedzi[10][6];
...
...
私有:系统::无效按钮单击(系统::对象^sender,系统::事件参数^e){
TabOdpowiedzi[1][1]=(Convert::ToString(textPO->Text));
this->textPN->Text=(Convert::ToString(TabOdpowiedzi[1][1]);
}
但我得到了这些错误,有什么问题吗?我如何将文本框中的输入保留为字符串以备将来使用,还是有更好的方法来保留文本输入以备将来使用

错误1错误C2679:二进制“=”:未找到接受类型为“System::String^”的右操作数的运算符(或没有可接受的转换)

错误2错误C2665:“System::Convert::ToString”:37个重载都不能转换所有参数类型

3 IntelliSense:没有与这些操作数匹配的运算符“=” 操作数类型为:std::string=System::string^

4 IntelliSense:重载函数“System::Convert::ToString”的实例与参数列表不匹配 参数类型为:(std::string)


您正在混合您的类型。声明

std::string TabOdpowiedzi[10][6];
作为

array^TabOdpowiedzi=gcnewarray(10,6);

<> p>你的问题消失了。也许你在代码的其他部分会有问题,但是你没有发布那些……/p>可能会对你有帮助。1。这是C++ + CLI,不是C++。为什么你要混合托管和非托管代码?<代码> STD::String 和 String。StrySystem::String^TabOdpowiedzi[10][6];生成这些错误:
Error 1 Error C2728:'System::String^”:本机数组不能包含此类型
2 IntelliSense:不允许使用句柄数组
啊抱歉,你是对的,你可以找到C++/CLI的正确语法。
array<System::String^,2>^ TabOdpowiedzi = gcnew array<System::String^,2>(10, 6);