将EnumerableRowCollection转换为List. [英] Convert EnumerableRowCollection to List.

查看:235
本文介绍了将EnumerableRowCollection转换为List.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在"j"变量中得到EnumerableRowCollection.
我想将"j"变量转换为List.

Hi Everybody,

I am getting EnumerableRowCollection in the "j" variable.
I would like to convert that "j" variable into a List.

var j = (from oce in ds.Tables[0].AsEnumerable()
                   select new PointView
                   {
                       ResponseId = oce.Field<string>("Responseid"),
                       latitude = oce.Field<decimal>("latitude"),
                       longitude = oce.Field<decimal>("Longitude")

                   });


我该怎么办?

我必须生成某些"X"类的List;基于上述EnumerableRowCollection.
这可能吗?

预先感谢.


How can I do that?

I have to generate List of some "X" class; based on the above EnumerableRowCollection.
Is this possible.?

Thanks in advance.

推荐答案



使用.ToList()淘汰方法...

Hi,

Use .ToList() extesion method...

var j = (from oce in ds.Tables[0].AsEnumerable()
                   select new PointView
                   {
                       ResponseId = oce.Field<string>("Responseid"),
                       latitude = oce.Field<decimal>("latitude"),
                       longitude = oce.Field<decimal>("Longitude")
 
                   }).ToList();



此处查看文档 [



Check documentation here [^].


这篇关于将EnumerableRowCollection转换为List.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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