0

How to create an alias for System.Int[]?

e.g.

using MyAlias = System.Int32[];

This wont compile.

But this will compile:

Defining type aliases

using MyAlias = System.Collections.Generic.List<System.Tuple<int, string, int>>;
...
public static MyAlias Foo()
{
  ...
}
zig
  • 4,524
  • 1
  • 24
  • 68
  • And better not do it anyway. What name can you choose so that it will be better (clearer) than int[] ?Think about other people who might later support your code. – Evk Mar 30 '18 at 12:10
  • 1
    @Evk, I guess it's up to me to decide what name to give it, specially in an internal implementation. in my case I would call it "ChecksumArray" which I repeatedly used in my internal class. and for example used different array type based on CPU architecture or other compiler directive. FYI, Delphi allows this kind of aliases with no issues at all. so I don't see what's the big deal about this... :) – zig Apr 11 '18 at 06:25
  • Well that makes sense, but anyway not possible. Maybe indeed worth using custom structure as one of the answers in duplicate proposes. – Evk Apr 11 '18 at 06:34

0 Answers0