StringBuilder 命名空间,C#,Visual Studio 2010
StringBuilder
属于哪个命名空间?
我输入:
using System.Text.StringBuilder;
但是智能感知不允许我输入 StringBuilder
。
What namespace does StringBuilder
belong to?
I typed:
using System.Text.StringBuilder;
But the intellisense, won't let me type StringBuilder
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
很容易确定 .NET 类位于哪个命名空间中。你有两种方法:
继承层次结构
部分你可以看到FULL类名。完整的类名意味着类名之前是它的命名空间。对于 StringBuilder,完整的类名将显示为 System.Text.StringBuilder。只需省略类名(StringBuilder),您就可以获得命名空间我总是使用第二种方式,因为它对我来说更容易。
Its very easy to determine in which namespace .NET class lives. you have two ways:
Inheritance Hierarchy
section you can see FULL class name. Full class name means that before class name would be its namespace. For StringBuilder full class name would face asSystem.Text.StringBuilder
. Just omit class name (StringBuilder) and you get namespaceI always use second way, because its more easy for me.
使用
指令“导入”命名空间,所以它应该读取using System.Text;
using
directives "import" namespaces, so it should readusing System.Text;
它位于 System.Text 命名空间中。
http://msdn.microsoft.com/en -us/library/2839d5h5(v=VS.100).aspx
如果您不确定某些内容位于哪个命名空间中,请将其输入编辑器(例如StringBuilder)并点击Ctrl .(控制点)以显示可能的命名空间。
然后,VS2010 会在文件中插入一个 using 声明。
It's in the System.Text namespace.
http://msdn.microsoft.com/en-us/library/2839d5h5(v=VS.100).aspx
If you're ever unsure what namespace something is in, type it into the editor (e.g. StringBuilder) and hit Ctrl . (control dot) to bring up the possible namespaces.
VS2010 will then insert a using declaration into the file for you.
删除 using 指令中的
.StringBuilder
。StringBuilder 是类本身。
Remove the
.StringBuilder
in your using directive.StringBuilder is the class itsself.
命名空间是 System.Text,而不是 System.Text.StringBuilder
The namespace is
System.Text
, not System.Text.StringBuilder或者,您也可以只输入
StringBuilder
,右键单击它,然后选择“Resolve >”。这样您就可以在不知道名称的情况下导入正确的名称空间。不过,您必须正确输入类名。Alternatively you can just type
StringBuilder
, right click it, and choose "Resolve >". This way you can import the right namespace without knowing the name. You'd have to type the class name correctly though.如果您添加了 .dll 文件作为参考(对于像这样基本的东西,您有参考),只需编写 StringBuilder (区分大小写)并按 Alt+Shift+F12 (或将鼠标悬停在它附近的小箭头上) ),您将看到可能的解决方案列表,其中之一是自动添加正确的使用,在本例中是:
If you have the .dll file added as a reference (and for something as basic as that, you have the reference), simply write StringBuilder (case-sensative) and hit Alt+Shift+F12 (or mouse over the small arrow near it) and you'll see a list of possible solutions, one of them will be to automatically add the correct using, which, in this case is:
StringBuilder 属于命名空间 - System.Text;
Namespace StringBuilder belong to - System.Text;