@Winston TheFifth , Welcome to Micosoft Q&A, you could try the following code to use List<T>.IndexOf Method to get the index based on the columnname.
string column_name="Age";
using (StreamReader sr = new StreamReader(path))
{
string line = sr.ReadLine();
var a = line.Split(',');
int index=a.ToList().IndexOf(column_name);
Console.WriteLine("index is "+index);
}
Csv and tested result:
Hope this could help you.
Best Regards,
Jack
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.