我想将var结果转换为数据表, [英] i wanted to convert var result in to data table,

查看:91
本文介绍了我想将var结果转换为数据表,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将结果转换为数据表,任何人都可以帮助查找

i want to convert result in to the datatable anyone can help to find out

private static async void PrintPrimaryNumbersAsync()
{
    for (int i = 0; i < 10; i++)
    {
        var result = await getPrimesAsync(i + 1, i * 10);
        result.ToList().ForEach(x => string.fromat(string.Format("This is generated async {0}", x)));
    }
}

public static Task<IEnumerable<int>> getPrimesAsync(int min, int count)
{
    return Task.Run(() => Enumerable.Range(min, count).Where
        (n => Enumerable.Range(2, (int)Math.Sqrt(n) - 1).All(i =>
        n % i > 0)));
}

推荐答案

看看这个:将列表转换为数据表 [ ^ ] - 它转换List< T>到DT,它应该适用于任何IEnumerable和微小的变化:所以你的Linq返回应该工作。
Have a look at this: Converting a List to a DataTable[^] - it converts a List<T> to a DT, and it should work fine with any IEnumerable with minor changes: so your Linq return should work.


这篇关于我想将var结果转换为数据表,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆