Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using directives

Status
Not open for further replies.

Dario1984

Technical User
Aug 23, 2005
12
AU
Hi.

I'm trying to use the using directive like a typedef in C++. Can I re-write the following to be legal in C# in any way ?

.....
using UidListType = System.Collections.Generic.List<UidType>;
using BodyTableType = System.Collections.Generic.Dictionary<string, UidListType>;
using FunctionTableType = System.Collections.Generic.Dictionary<string, BodyTableType>;
....

In other words, can a Using directive be dependent on the Using directive above it ?
 
No, it's not intended to be used in that manner. There are two ways to use the [tt]using[/tt] keyword:

1. In class and namespace scope, the [tt]using[/tt] keyword allows you to import another namespace so that your code is more compact.

2. Inside methods, the [tt]using[/tt] keyword surrounds a block of code, and acts as a compact implementation of the IDisposable interface, to protect you from resource leaks.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top