Skip to content

Use IList or IEnumerable instead of List in method parameters #605

Closed
@Swimburger

Description

@Swimburger

There may be a reason List<T> is used instead of IList<T> or IEnumerable<T>, but I'd like to be able to pass in other types of collection classes, specifically T[].

For example, here's a snippet that generates TwiML that will gather some input:

var voiceResponse = new VoiceResponse()
    .Gather(
        input: new List<Gather.InputEnum> {Gather.InputEnum.Dtmf}
    );

It works fine, but if the input parameter would accept IList<Gather.InputEnum> or IEnumerable<Gather.InputEnum>, we could pass in an array instead:

var voiceResponse = new VoiceResponse()
    .Gather(
        input: new[]{Gather.InputEnum.Dtmf}
    );

This is super minor, but this would make the APIs a little more flexible and allow developers to write shorter/less verbose code IMO.
This isn't the only location List<T> is specified, so I'd like to see it changed, if possible, wherever :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions