juststeve
asked on
How to convert List to Enumberable
I'm creating a value from a method that returns an IEnumerable and attempting to send it to a method:
I've tried a few different Cast syntaxes without finding the correct one. I keep hitting:
Error 24 Argument 1: cannot convert from 'System.Collections.Generi c.IEnumera ble<App.Bu siness.Err orInfo>' to 'System.Collections.Generi c.IList<Ap p.Business .ErrorInfo >'
public RulesException(IList<ErrorInfo> errors)
I've tried a few different Cast syntaxes without finding the correct one. I keep hitting:
Error 24 Argument 1: cannot convert from 'System.Collections.Generi
The only I know is to iterate through the Enumerable and to add them one by one to the list.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The question sounds like "How to convert List to Enumberable". However you like to do opposite.
FernandoSoto showed one way. Another is to use a List constructor:
List<T>(IEnumerable<T>). See http://msdn.microsoft.com/en-us/library/d0cyc8ex.aspx
So, you do something like:
RulesException(new List<ErrorInfo>(myEnumerab leValue);
FernandoSoto showed one way. Another is to use a List constructor:
List<T>(IEnumerable<T>). See http://msdn.microsoft.com/en-us/library/d0cyc8ex.aspx
So, you do something like:
RulesException(new List<ErrorInfo>(myEnumerab