【发布时间】:2017-11-21 12:22:01
【问题描述】:
嘿,我正在尝试将在文本框中输入的文本保存为字符串
#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]));
}
但是我收到了这些错误,怎么了?如何将文本框中的输入保留为字符串以供将来使用,或者有更好的方法来保留文本输入以供将来使用?
错误 1 错误 C2679:二进制“=”:未找到采用“System::String ^”类型右侧操作数的运算符(或没有可接受的转换)
错误 2 错误 C2665: 'System::Convert::ToString' : 37 个重载中没有一个可以转换所有参数类型
3 IntelliSense:没有运算符“=”与这些操作数匹配 操作数类型为:std::string = System::String ^
4 IntelliSense:没有重载函数“System::Convert::ToString”的实例与参数列表匹配 参数类型是:(std::string)
【问题讨论】:
-
This 可能会对您有所帮助。
-
1.这是 C++/CLI,而不是 C++。为什么要混合托管和非托管代码?
std::string和System.String是不同的类型,可能更容易选择并使用它。
标签: string text textbox c++-cli