Logo 
Search:

C# FAQ

Submit Interview FAQ
Home » Interview FAQ » C#RSS Feeds

Can I use typedefs in C#?

  Shared By: Evelyn Hughes    Date: Dec 15    Category: C#    Views: 698

Answer:

No, C# has no direct equivalent of the C++ typedef. C# does allow an alias to be specified via the using keyword:

using IntList = System.Collections.Generic.List<int>;
but the alias only applies in the file in which it is declared. A workaround in some cases is to use inheritance:

public class IntList : List<int> { }

Share: 
 

Didn't find what you were looking for? Find more on Can I use typedefs in C#? Or get search suggestion and latest updates.


Your Comment
  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].


Tagged: