LINQ和ArrayList的使用 [英] Use of LINQ and ArrayList

查看:179
本文介绍了LINQ和ArrayList的使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近使用过LINQ

I've recently used LINQ

在以下代码中:

ArrayList list = new ArrayList();
var myStrings = list.AsQueryable().Cast<string>();

AsQueryable的作用是什么?我知道Cast创建一个类型安全的集合,而ArrayList已弃用.

What is the AsQueryable for? I know Cast creates a type-safe collection, and ArrayList is deprecated.

我有一个朋友说他需要将AsQueryableArrayList结合使用.我试图了解原因,但看不到为什么需要AsQueryable.

I've got a friend who says he needs the AsQueryable combined with ArrayList. I'm trying to understand why, but I can't see why AsQueryable is needed.

他错了吗?

推荐答案

AsQueryable将用于生成一个IQueryable,如果实现了该IQueryable,则可以通过表达式树分析查询以将其重写或翻译成其他类似语言的形式例如,使用linq to sql.

AsQueryable would be used to produce an IQueryable which can then, if implemented, analyse the query via expression trees to rewrite it or translate it into some other language-like with linq to sql for example.

在这种情况下,这完全没有意义,您可以告诉您的朋友不要打扰.

In this case it is completely pointless and you can tell your friend not to bother.

这篇关于LINQ和ArrayList的使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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