Namespaces disambiguate class names inside of class libraries or applications.

You must reference class names by their full name.

System.Text.StringBuilder sb = new System.Text.StringBuilder();

…. or, you can employ a using directive at the top of the code file to instruct the compiler to look in those namespaces to find the class that is referenced.

using System.Text;

................

StringBuilder sb = new StringBuilder();

You must always do this if the code you are writing is outside of the namespace of the class you want to use, even if it is in the same project.

Default namespace defined in Project Properties(right clicking on Project name in Solution Explorer, select Properties……)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.