Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

throw null in decompiled ArraySegment

Tags:

.net

.net-core

I've just had a look at the ArraySegment class in .NET Core (...\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Runtime.dll).

Every method\property just has throw null in it:

public T[] Array
{
  get
  {
    throw null;
  }
}

What's this for? How does it work?

like image 826
BanksySan Avatar asked Sep 13 '26 23:09

BanksySan


1 Answers

You're looking at the reference assemblies. That's not the real implementation - it's just a placeholder to compile against, effectively.

You'll see the assembly only has the public/protected members, and every code-based member (property, constructor, method etc) is implemented like this.

The point is to create an assembly which is as small as it can be, but which the compiler can use as a reference. At execution time, the real code is present instead.

like image 90
Jon Skeet Avatar answered Sep 16 '26 20:09

Jon Skeet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!