I need to split an array of indeterminate size, at the midpoint, into two separate arrays.
The array is generated from a list of strings using ToArray().
public void AddToList ()
{
bool loop = true;
string a = "";
Console.WriteLine("Enter a string value and press enter to add it to the list");
while (loop == true)
{
a = Console.ReadLine();
if (a != "")
{
mylist.Add(a);
}
else
{
loop = false;
}
}
}
public void ReturnList()
{
string x = "";
foreach (string number in mylist)
{
x = x + number + " ";
}
Console.WriteLine(x);
Console.ReadLine();
}
}
class SplitList
{
public string[] sTop;
public string[] sBottom;
public void Split(ref UList list)
{
string[] s = list.mylist.ToArray();
//split the array into top and bottom halfs
}
}
static void Main(string[] args)
{
UList list = new UList();
SplitList split = new SplitList();
list.AddToList();
list.ReturnList();
split.Split(ref list);
}
}
}