Skip to content

foreach/else #134

Description

@lyubomyr-shaydariv

The following proposal's value may be really low, nothing revolutionary, but sometimes one may need the code like the following:

// bar is an IEnumerable<T>
foreach ( var foo : bar ) {
    Console.WriteLine(foo);
} else {
    Console.WriteLine("no foos in the bar");
}

Just a little syntax sugar.

EDIT

Please note that there would be no a straightforward extension method: foreach might contain break, continue and return.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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