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.

Kirtan PatelRank #292 · 8.6K reputationPosted May 12, 2009, 10:58 AM EDT
string[] Trux_Info = new string[20];
Trux_Info[3] = "Hello";
string str = Trux_Info[3];
MessageBox.Show(str);
zirano latt20 reputationPosted May 12, 2009, 10:10 PM EDT
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.