私は^(オブジェクト演算子へのハンドル)はどのように機能しますか?
textBox1->Text = textBox1->Text->Remove(textBox1->Text->Length - 1);
でてtextBoxからの最後の文字を削除することができ、私はそれがテキストへの参照やポインタを作成したいと思います。しかし、私はこの
String^ t = textBox1->Text;
t = t->Remove(t->Length - 1); // Text doesn't change
P.S.のようにそれを行うことはできませんこのいずれかがコンパイルされません。Remove
によって返される文字列を参照するために、t
String* t = textBox1->Text; // error: an ordinary pointer to a
// C++/CLI ref class or interface class
// is not allowed
String& t = textBox1->Text; // error: an ordinary reference to a
// C++/CLI ref class or interface class
// is not allowed
String% t = textBox1->Text // error: a tracking reference to a
// System::String is not allowed
.NETの文字列は不変です。代わりにTextBoxコントロールへの参照を格納します。 –
@CodyGray:ちょっと好奇心から(私はC++に慣れていない)、 'textBox1'のタイプは? –
@CodyGrayでも、 't-> Remove'では新しい文字列を作成しませんか? – Pavel