var gender = from row in excel.Worksheet()
select row["Gender *"].Value.ToString();
string[] genderArray = gender.ToArray().Distinct().ToArray();
in this case the content of genderArray are { "F" , "M" , "M "}
i want that genderArray should only contain { "F" , "M" }
var gender = (from row in excel.Worksheet()
select row["Gender *"].Value.ToString()) ;
string[] genderArray = gender.ToArray().Distinct().Select(g=>g.Trim()).ToArray();
You can also do the .Trim in the first query against Value.ToString().Trim(). Edited: I might have misplaced the select in the query.
var gender = (from row in excel.Worksheet()
select row["Gender *"].Value.ToString().Trim()) ;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With