I am attempting to iterate an IEnumerable of an object using LINQ, and pull out a certain property of every object into an IEnumerable of the type of that property.
I am currently doing it with the SelectMany LINQ expression, but instead of returning an IEnumerable<string> which I want (as the property is a string), it is returning an IEnumerable<char>
var propertyValues = objectCollection.SelectMany(o => o.Value);
What am I missing?
If it is returning an
IEnumerable<char>then that is what it is. At a guess you want to use Select() and not SelectMany(), I would guess it is flattening a bunch of strings as anIEnumerable<char>. If you can post more code that shows what is inobjectCollectionwe might be able to help more.EDIT
bit more code to illustrate my point