简体   繁体   English

我怎样才能在boo中使用扩展方法

[英]How can i use Extension Methods in boo

I have a list in my boo script and want to use System.Linq Extension Methods but boo compiler throw this Exception: 我的boo脚本中有一个列表,并希望使用System.Linq扩展方法,但boo编译器抛出此异常:

BCE0019: Boo.Lang.Compiler.CompilerError: 'ToList' is not a member of 
'System.Linq.IQueryable`1[[...]]'.

("..." is type of my object) (“......”是我的对象的类型)

What version of Boo? 什么版本的Boo? Extension Methods have been supported since 0.9.0. 自0.9.0以来一直支持扩展方法。 If you can't use extension methods with the version you are using, you'll have to use absolute method calls, eg Enumerable.Select(...). 如果您不能对您使用的版本使用扩展方法,则必须使用绝对方法调用,例如Enumerable.Select(...)。

As @Jean has said, have you also imported System.Linq ? 正如@Jean所说,你还导入了System.Linq吗?

I should import System.Linq.Enumerable not System.Linq 我应该导入System.Linq.Enumerable而不是System.Linq

thanks Jean and Matthew for your answers. 感谢Jean和Matthew的回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM