为什么 VS 2008 在 Intellisense 中不显示 String 类的扩展方法 [英] Why doesn't VS 2008 display extension methods in Intellisense for String class

查看:22
本文介绍了为什么 VS 2008 在 Intellisense 中不显示 String 类的扩展方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于 String 实现了 IEnumerable,我期待在 Intellisense 中看到 Enumerable 扩展方法,例如,在

Since String implements IEnumerable<char>, I was expecting to see the Enumerable extension methods in Intellisense, for example, when typing the period in

String s = "asdf";
s.

我期待看到 .Select(...).ToList() 等.然后我惊讶地看到扩展方法 do 实际上适用于字符串类,它们只是没有出现在 Intellisense 中.有人知道为什么是这样吗?这可能与这个有关 问题.

I was expecting to see .Select<char>(...), .ToList<char>(), etc. I was then suprised to see that the extension methods do in fact work on the string class, they just don't show up in Intellisense. Does anyone know why this is? This may be related to this question.

推荐答案

这是明确的设计.问题在于,虽然 String 绝对实现了 IEnumerable,但大多数人并没有想到它,或者更重要的是没有以这种方式使用它.

It's by explicit design. The problem is that while String most definitely implements IEnumerable<T>, most people don't think of it, or more importantly use it, in that way.

String 的方法数量很少.最初我们没有过滤掉 String 的扩展方法,结果是很多负面反馈.有时,如果导入正确,它的方法数量几乎翻了三倍.显示所有扩展方法后,人们通常无法在噪音中看到他们正在寻找的 String 方法.

String has a fairly small number of methods. Initially we did not filter extension methods off of String and the result was a lot of negative feedback. It almost tripled the number of methods at times with the right imports. With all of the extension methods displayed, people often couldn't see the String method they were looking for in the noise.

String 是一种 ... 简单类型,最好以这种方式查看 :)

String is a ... simple type and it's better to view it that way :)

仍然完全可以在字符串上调用扩展方法.它很可能不会出现在智能感知中.

It's still completely possible to call an extension method on string. It's just likely not going to show up in intellisense.

String 实际上有很多方法.但是因为它们中的许多都是过载,所以它们在智能感知中崩溃了.

String actually has quite a few methods. But because many of them are overloads they collapse in intellisense.

这篇关于为什么 VS 2008 在 Intellisense 中不显示 String 类的扩展方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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