typedef

  • Thread starter Thread starter Aleksey
  • Start date Start date
A

Aleksey

Hi, all!

Is there a typedef in C#? Or how can I create my alias on built-in type?

Thanks a lot
 
There is no typedef per se in C#, however you can get close with the using
keyword. The most common use of the using keyword is in a using Directive
which “Creates an alias for a namespace or imports types defined in other
namespacesâ€
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vclrfusingdirective.asp)
You’ve probably already seen this with ‘using System.Xml;’ and so on at the
top of a .cs... you can also use it to define your own alias ala:

using MyInt = System.Int32;

And within the scope the above is defined, MyInt will be treated as
System.Int32.

Brendan
 
The problem with that the alias is only valid in the sourcefile where is is
declared.
 

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

Back
Top