Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Alias-ing any type was added in C# 12 - do you mean something more than this? https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/cs...


In this case aliasing refers to memory aliasing. As in, given a common struct that represents a type union, you can overlap the fields that satisfy 'unmanaged' constraint (think int, MyStruct(short, long), Guid) between each other, but you cannot overlap them with fields that are or contain object references, because this violates the spec and GC will likely crash upon encountering data that turns into garbage when interpreted as a pointer.


An official proposal was just submitted for type unions:

https://github.com/dotnet/csharplang/blob/18a527bcc1f0bdaf54...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: