Language Enhancement Idea

  • Thread starter Thread starter Matt Osborne
  • Start date Start date
M

Matt Osborne

I don't know if this is the correct forum to propose a new feature for the
C# languange, but I thought I would do so anyway.

I was working on a project and thought of a feature that would possibly
help many developers. It was the adition of a new loop that crossed a
foreach and a do loop. The syntax would be something like:

foreach ( object obj in collection )
{
statement;
} while ( condition == true );
 
The more difficult, but also more elegant way, would be to write a new
IEnumerator for what you are trying to accompish. I have several
enumerators that filter and do things to other enumerators. I'll have to
think about it, but it may be possible to write an enumerator with some sort
of break condition.

I'll get back if I find anything elegant.

This will of course be easier with C# 2.0's iterators...but I digress.

--Matthew W. Jackson
 
Matt Osborne said:
I don't know if this is the correct forum to propose a new feature for the
C# languange, but I thought I would do so anyway.

I was working on a project and thought of a feature that would possibly
help many developers. It was the adition of a new loop that crossed a
foreach and a do loop. The syntax would be something like:

foreach ( object obj in collection )
{
statement;
} while ( condition == true );

Since it is trivial to get the same effect with:

foreach (object obj in collection)
{
statement;
if (condition == false)
break;
}

I'd say it is not worth adding another construct to the language.

Regards,
Sami
 
Maybe the OP would give us some more
info, like maybe what advantages this has
over the way just mentioned in this reply?
 
The upcomming "annonymous methods" feature may provide some of the
functionality you are looking for.
 
Back
Top