using keyword
http://www.csharpfriends.com
World's Greatest C# Community    
Home Articles C# Forums Books C# Syntax C# Spec C# Jobs free Source Code Advertise About
 

Control Panel

[ Sign In / register ]
Points   
Notes 
My Forums
My Tutorials
My Profile

Resources

Learn
 Articles
 QuickStarts
 C# Spec
 Whitepapers
 Tools
 Class Browser
 C# Code Generator
 Links
 Misc Rss Feeds
 Code Highlight
 411 Directory
 FREE magazines
 freevb.net

Reviews
  ASP.NET Hosting

Source Code
 Get Version 1.0



C# Consulting
AspDotNetStoreFront
Chapter:   UnCategorized
Current Lesson:
using keyword
[Latest Content]
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | ALL
[prev. Lesson]  volatile keyword [next Lesson]  unsafe keyword
using keyword
  by: Salman Ahmed

using

The using directive can be used in 2 different ways:

  • as an alias for a namespace
  • allows you to use types of a particular namespace without the need for qualifying the entire namespace
using [alias = ] class_or_namespace;
where:

alias(optional) - a user defined symbal that is representing a namespace. class_or_namespace - is the namespace name that you wish to either use or alias, or the class name that you wish to alias. Key Points:

Common use of using is to make life easier so you don't have to fully quality ever statement.

Create a using directive to use the types in a namespace withough having to specify that actual namespace.

A using directive does not give you access to any of the various namespaces that might be nested in the namespace that you specified.

A user defined namespace is referring to any namespace you have created in yuor code.

Example:

// using keyword
using System;
using CSF = CSharpFriends.BestResource.ForCSharp;  // alias 

namespace CSharpFriends.BestResource
{
    public class MyClass
    {
        public static void DoNothing()
        {
            //empty
        }
    }

    namespace ForCSharp
    {
        public class MyNestedClass
        {
            public static void MyMessage()
            {
                System.Console.WriteLine("CSharpFriends!");
            }
        
        }        
    
    }

}
public class TestUsing
{
    public static void Main()
    {
        CSF.MyNestedClass.MyMessage();
        
        // pauses output window
        Console.ReadLine();
    }
}

1 


Build Your Own ASP.NET Website Using C# & VB.NET

Chapter:  UnCategorized
Current Lesson:
using keyword
[Latest Content]
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | ALL
[prev. Lesson]  volatile keyword [next Lesson]  unsafe keyword


Today's Top Movers
vulpes 6800
MadHatter 2220
jal 867
Jeff1203 857
muster 791

Yesterday Top Movers
shakti sin.. 9
MadHatter 3
Al_Pennywo.. 2
C#fanatic 2
goraperas 1

Monthly Leaders
vulpes 6800
MadHatter 2260
jal 867
Jeff1203 857
muster 791

Top Members
mosessaur 18457
Rincewind 7074
stanleytan 6995
vulpes 6800
Gsuttie 6046

Great Offers
.net hosting
Go To My Pc
Remote Pc Control
zonealarm
spam blocker
web hosting directory
ad server   C#
snadtech GoToMyPc

Top of Page

Advertise | About | Link To Us | Privacy Notice Copyright © 2003 - 2005 CSharpFriends.com  All Rights Reserved  Visual C# Developer Center