Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MessageBox.show() C# problem

Tags:

c#

see this code:

ChooseGrade ChGrade = new ChooseGrade();
string GrCl = ChGrade.getGrCl().ToString(); // function getGrCl gets "public int[] grad_class=new int[2];" in ChooseGrade Class
MessageBox.Show(GrCl);

But I see in Messagebox this "System.Int32[]" instant container of grade_class Array. Can you Help me?

like image 689
Erfan Avatar asked Aug 26 '26 08:08

Erfan


2 Answers

Enumerate over the ints and add them to a string which you can then show in the MessageBox:

string message = "";
int myArray[] = ChGrade.getGrCl();

foreach(var num in myArray)
    message += String.Format("{0} ", num);

MseeageBox.Show(message);
like image 123
alex Avatar answered Aug 27 '26 21:08

alex


The default ToString()-implementation returns the type. Since the return value of getGrCl() is an array of integer, the ToString()-method returns just this.

like image 26
Dennis Traub Avatar answered Aug 27 '26 22:08

Dennis Traub