C# Async Streams
2021-07-02 19:03
标签:reac com 技术 rsa load stream class new yield 先看代码 上部分执行结果如下图 注释 main 函数 return ;之前的代码 执行结果如下图 C# Async Streams 标签:reac com 技术 rsa load stream class new yield 原文地址:https://www.cnblogs.com/microestc/p/14961522.htmlusing System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace AsyncStream
{
class Program
{
static async Task Main(string[] args)
{
var product = new Productor();
var numbers = await product.GetNumbersAsync();
foreach(var number in numbers)
{
Console.WriteLine(number);
}
return;
await foreach(var number in product.EnumerateNumbersAsync())
{
Console.WriteLine(number);
}
}
}
public class Productor
{
public async Task
static async Task Main(string[] args)
{
var product = new Productor();
// var numbers = await product.GetNumbersAsync();
// foreach(var number in numbers)
// {
// Console.WriteLine(number);
// }
// return;
await foreach(var number in product.EnumerateNumbersAsync())
{
Console.WriteLine(number);
}
}