Interview Questions

Can I define a type that is an alias of another type (like typedef in C++)?

C# Interview Questions and Answers


(Continued from previous question...)

95. Can I define a type that is an alias of another type (like typedef in C++)?

Not exactly. You can create an alias within a single file with the "using" directive: using System; using Integer = System.Int32; // alias
But you can't create a true alias, one that extends beyond the file in which it is declared. Refer to the C# spec for more info on the 'using' statement's scope.

(Continued on next question...)

Other Interview Questions