int to system::string

i have been screwing around with the windows GUI recently and textboxes use system::string type, i have a function that returns an int value and i need it to appear in the text box so i need to convert an int to a system::string. here is my current code:
1
2
3
4
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
				 
				 textBox1->Text = myfunc(3,4); 
			 }


visual studio gives me these errors:
Error 1 error C2664: 'void System::Windows::Forms::Control::Text::set(System::String ^)' : cannot convert parameter 1 from 'int' to 'System::String ^'

so i basically just need to convert my integer to a system string could anyone tell me how to do that
hello like2codecpp,

you can use System::Convert::ToString(...)
i still get the same errors, where do i put this snippet, is it like this:
1
2
3
4
5
6
7
8
9
10
int myfunc(int a, int b)
{
	int c;

	c = a*b;

	System::Convert::ToString(c);
	
	return c;
}
What do you think System::Convert::ToString(...); is doing? No magic is involved instead it converts int to string. So put it where it's needed.

textBox1->Text = System::Convert::ToString(myfunc(3,4));

and check if it throws
Topic archived. No new replies allowed.