I have a program that opens a CSV file using StreamReader and creates a table with 4 columns and rows for however many rows are in the CSV file. This works correctly as is creating the output of:
Item Code, Item Description, Current Count, On Order
A0001, Toy Car, 4, Yes
A0002, Toy Truck, 1, No
I save all the data from the CSV file in a global list without splitting each line. When I am creating the table I split the lines using "Split(',')", which works as needed at the time. However I am unsure how to reorder the whole list using the Current Count column from largest to smallest. I have tried the following but it give an error on the Split(',').
public static class Globals
{
public static List<string> items = new List<string>();
}
private void createTableWithOrder(int order)
{
for (int i = 0; i < Globals.items.; i++)
{
var values = Globals.items[i].Split(',');
if (order == 1)
{
values = Globals.items[i].OrderBy(itemDesc => itemDesc.Split(',')).ToList();
}
}
}
The Error given is below:
'char' does not contain a definition for 'Split' and no extension method 'Split' accepting a first argument of type 'char' could be found (are you missing a using directive or an assembly reference?)