I have defined the following extension method:
public static void ForEach<T>(this IEnumerable<T> sequence, Action<T> action)
{
foreach (T obj in sequence)
{
action(obj);
}
}
Then I can use it like:
new [] {1, 2, 3}
.ForEach(n =>
{
});
I want to be able to use continue, and breakthe inside of my extension method so that I can:
new [] {1, 2, 3}
.ForEach(n =>
{
if(n == 1) { continue; }
if(n == -1) { break; }
});
Are these keywords are used only in cycles for, foreach, whileor do-while?
MaYaN source
share