I would do something like this: List<int> myInts = new List<int>();
then in your for loop do: myInts.Add(Convert.ToInt32(values[i]));
And if you really want an integer array, you can always use the ToArray method of the List class.
OP's probably referring to having an array of int's not string's. something like this might work:
//declare list of ints
List<int> test = new List<int>();
System.IO.StreamWriter sw = new System.IO.StreamWriter("Test.txt");
//initiate reading from the file
System.IO.StreamReader sr = new System.IO.StreamReader("Test.txt");
//loop through each line of the file
//read a line of the file. split the line into a temporary array using `,` as delimiter, then loop through
foreach (string s in sr.ReadLine().Split(','))
//convert each string to an int and add it to the list
//a test loop to show the values in the list
foreach (int I in test)
Dopn't be put off by using a List. Lists are basically dynamic arrays, and with the ability to add and remove items with one command, much easier to use in many respects. Also as was mentioned if you need to pass it as an array you can use the ToArray() method.
Now i need to read this array.Suppose it has values 131221 and if 1 means A, 3 means B and 1221 means E..then i need to display that file contains one A, one B and one E.
If it reads 112213 then it should display on A,one E and one B.
How should i do this?
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...