-
Notifications
You must be signed in to change notification settings - Fork 8
/
Program.cs
38 lines (30 loc) · 851 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
await foreach (string line in ReadLinesAsync(args[0]))
{
Console.WriteLine(line);
}
static async IAsyncEnumerable<string> ReadLinesAsync(string path)
{
using (var bodyTextReader = new StreamReader(path))
{
while (!bodyTextReader.EndOfStream)
{
string? line = await bodyTextReader.ReadLineAsync();
if (line is not null) { yield return line; }
}
}
}
// These examples illustrate features that are built into .NET. We don't
// want to define it ourselves, hence the #if false
#if false
bool MoveNext();
public interface IAsyncEnumerable<out T>
{
IAsyncEnumerator<T> GetAsyncEnumerator(
CancellationToken cancellationToken = default);
}
public interface IAsyncEnumerator<out T> : IAsyncDisposable
{
T Current { get; }
ValueTask<bool> MoveNextAsync();
}
#endif