mirror of https://github.com/icsharpcode/ILSpy.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1020 B
50 lines
1020 B
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
|
|
namespace ICSharpCode.Decompiler.Tests.TestCases.Ugly |
|
{ |
|
internal class NoForEachStatement |
|
{ |
|
public static void SimpleNonGenericForeach(IEnumerable enumerable) |
|
{ |
|
IEnumerator enumerator = enumerable.GetEnumerator(); |
|
try |
|
{ |
|
while (enumerator.MoveNext()) |
|
{ |
|
#if ROSLYN && OPT |
|
Console.WriteLine(enumerator.Current); |
|
#else |
|
object current = enumerator.Current; |
|
Console.WriteLine(current); |
|
#endif |
|
} |
|
} |
|
finally |
|
{ |
|
IDisposable disposable = enumerator as IDisposable; |
|
if (disposable != null) |
|
{ |
|
disposable.Dispose(); |
|
} |
|
} |
|
} |
|
|
|
public static void SimpleForeachOverInts(IEnumerable<int> enumerable) |
|
{ |
|
using (IEnumerator<int> enumerator = enumerable.GetEnumerator()) |
|
{ |
|
while (enumerator.MoveNext()) |
|
{ |
|
#if ROSLYN && OPT |
|
Console.WriteLine(enumerator.Current); |
|
#else |
|
int current = enumerator.Current; |
|
Console.WriteLine(current); |
|
#endif |
|
} |
|
} |
|
} |
|
} |
|
}
|
|
|