Skip to content

Cannot implicitly convert type with IEnumerable #13

@Rasphino

Description

@Rasphino

Hi Amichai, I have a problem when trying to wrap an IEnumerable to an ErrorOr<IEnumerable>:

using ErrorOr;

class Foo {
    public ErrorOr<IEnumerable<int>> wrap() {
        IEnumerable<int> nums = new List<int>(){ 1, 2 };
        return nums;   
    }
}

VSCode gives me an error:

Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<int>' to 'ErrorOr.ErrorOr<System.Collections.Generic.IEnumerable<int>>' [BuberDinner.Api]csharp(CS0029)
No quick fixes available

I find a workaround: changes IEnumerable<int> tools to List<int> tools:

using ErrorOr;

class Foo {
    public ErrorOr<IEnumerable<int>> wrap() {
        List<int> nums = new List<int>(){ 1, 2 };
        return nums;   
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions