I guess you are using dataset (datatable) or some list to store the data after you read from CSV. If that is the case use a sequence column that shows the sequence of the records readed from the CSV. After this you can use linq to make query on this dataset or list. First get the list of the distinct names and then you can query on the sorted list to get the last and the first item. Something liek this (I did not tested!):
var DistinctUsers = (from i in table.AsEnumerable() select new { name = i.Field<string>("UserName") }).Distinct();
var firstLast = from i in table.AsEnumerable() orderby i.Field<int>("SeqNumber") select i;
firstLast.First();
firstLast.Last();