问题
What namespace does StringBuilder
belong to?
I typed:
using System.Text.StringBuilder;
But the intellisense, won't let me type StringBuilder
.
回答1:
Its very easy to determine in which namespace .NET class lives. you have two ways:
- Find interesting class in MSDN and in
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 namespace - Open Object browser in VS and search for interesting class. In results, click on the class and in detail view interesting information will appear:
I always use second way, because its more easy for me.
回答2:
using
directives "import" namespaces, so it should read using System.Text;
回答3:
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.
回答4:
Remove the .StringBuilder
in your using directive.
StringBuilder is the class itsself.
回答5:
The namespace is System.Text
, not System.Text.StringBuilder
回答6:
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.
回答7:
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:
using System.Text
回答8:
Namespace StringBuilder belong to - System.Text;
来源:https://stackoverflow.com/questions/6261441/stringbuilder-namespace-c-visual-studio-2010