CSharpFunctionalExtensions
CSharpFunctionalExtensions copied to clipboard
Error : Cannot implicitly convert type
The following code:
IEnumerable<string> list = new List<string>();
Maybe<IEnumerable<string>> maybeList = list; // line in error
gives me the error
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable
' to 'CSharpFunctionalExtensions.Maybe<System.Collections.Generic.IEnumerable >'
Instead, the following code, works perfectly:
List<string> list = new List<string>();
Maybe<IEnumerable<string>> maybeList = list;
Any hint?
I just ran into a similar problem. I noticed there is a From static method on the Maybe type though, and it allowed me to work around this problem:
var thing = Maybe<IThing>.From(other.ContainsKey(key) ? other[key] : null);
// thing is now Maybe of IThing