Moving an array element to a variable.
When I started I didn't think just taking an element and copying to a variable was such a hassle.
OK, I have a string array defined as:
public static string[] Trux_Info = new string[20];
and I have a varaible define as
public static string port_in = "";
Now I thought that something like
port_in = Trux_Info[3]
would work. It didn't. I tried Trux_Info.GetValue(3). It didn't work right.
I know Trux_Info has info I can print to screen\file and the right info is there. I even passed the array across child, parent and back to a different child, the info is there.
I really need this element to go to this single variable, because after this happens then the processing can begin.
Any and all suggestion are appreciated.
Thanks N.
zirano lattPosted May 13, 2009, 2:10 AM
int[] a = new int[100];
Console.write(a[99]); // write 0 as int is value type and initialized default value to 0
string[] a= new string[100]
Console.write(a[99]); // write nothing as string is ref type and allocated as null value.
Console.write(a[99].ToString()); //error as accessing to the member of null object.
Kirtan PatelPosted May 12, 2009, 2:58 PM
string[] Trux_Info = new string[20];
Trux_Info[3] = "Hello";
string str = Trux_Info[3];
MessageBox.Show(str);