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

  • Thread starter Thread starter Swapnil
  • Start date Start date
S

Swapnil

hi,

we can use Typedef in C++ . To perform the same operation in C# How can i
use?
Please Explain with example.
 
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");
 
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.
 
Back
Top