我是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支持扩展方法动态关键字?
发布评论