I'm new to linq. I have a string having the following format
code:description;code2:description2;code3:description3... etc.
Records are separated with ; character and each record has 2 fields separated with : character.
I'm writing a linq query to extract a list of objects having as fields code and description. I have written the following query which seems to produce correct results, but I was wondering if there is a better or more correct way to do it.
var objects =
from objString in recsString.Split(';')
let obj = objString.Split(':')
select new {
Code = obj[0].Trim(),
Description = obj[1].Trim()
};
:or;in code or description, or if any entry is empty or half-empty. Other than that its fine.