How to convert a ISingleResult<T> containing a string to a string array
I am tempted to loop through the results and just add it to the string array but I'm sure there must be a better way.
My sproc returns a ISingleResult<T>
(开发者_如何学编程where T is just a class with 1 string).
I want to return this list as a string[]. Is there any way to do this without using foreach loop?
ISingleResult inherits IEnumerable
IEnumerable has an extension method called ToArray.
Edit sorry, missed that T was a class, not String. So it would be
ISingleResultValue.Select(x=>x.StringProperty).ToArray();
精彩评论