Like Typedef(In C++) operation what is option in C#.

S

Swapnil

hi,

we can use Typedef in C++ . To perform the same operation in C# How can i
use?
Please Explain with example.
 
J

Jon Skeet [C# MVP]

Swapnil said:
we can use Typedef in C++ . To perform the same operation in C# How can i
use?
Please Explain with example.

There's no project-wide equivalent of typedef.

You can use using directives on a per file basis, e.g.

using FooBar = System.Console;

....

FooBar.WriteLine("Hi");
 
J

Jeroen Mostert

Jon said:
There's no project-wide equivalent of typedef.

You can use using directives on a per file basis, e.g.

using FooBar = System.Console;
It's also common to simply derive a class when dealing with generic instances:

class MySpecialCollection : Dictionary<MyKeyType, MyValueType> {
// add constructors as required
};

This is self-documenting and reduces the potential for typing errors.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top