将在C#4支持扩展方法动态关键字?

编程入门 行业动态 更新时间:2024-10-11 11:14:53
本文介绍了将在C#4支持扩展方法动态关键字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是listening一讲关于 C#4 的动态关键词,我想知道......请问这个功能是正交的其他.NET功能,例如将它支持扩展方法?

I'm listening to a talk about C#4's dynamic keyword and I'm wondering... Will this feature be orthogonal to other .NET features, for example will it support extension methods?

public static class StrExtension { public static string twice(this string str) { return str + str; } } ... dynamic x = "Yo"; x.twice(); // will this work?

注意:被问到这个问题C#4被运前,这就是为什么它在未来的措辞紧张

Note: This question was asked before C#4 was shipped which is why it's phrased in the future tense.

推荐答案

从\"New在C#4的Word文档特点:

动态查找将不能够  找到扩展方法。是否  扩展方法适用与否取决于  关于该呼叫的静态上下文  (即其使用条款发生),和  此上下文信息是不  目前保存为有效载荷的一部分。

Dynamic lookup will not be able to find extension methods. Whether extension methods apply or not depends on the static context of the call (i.e. which using clauses occur), and this context information is not currently kept as part of the payload.

更多推荐

将在C#4支持扩展方法动态关键字?

本文发布于:2023-11-12 11:10:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581328.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:将在   关键字   方法   动态

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!