Re:Announcing .NET Core 2.1
by zamalek on Wednesday May 30, 2018 @08:48PM
(#17193142)
Span (safely refers to data anywhere) and Memory (safely refers to data on the heap only) have a much nicer API than arrays. ArraySegment has had a facelift but to nit: ArraySegment is a pain to type. Also, unlike arrays, there are read-only variants - which are good for rich type checking. In addition you can easily reinterpret cast between blittable types (the new 'unmanaged' generic constraint) for when you are participating in mortal sins such as directly serializing byte representations.
Tons of reasons to use them besides performance. We use them for those reasons and if there is a performance boon, great bonus!
Tons of reasons to use them besides performance. We use them for those reasons and if there is a performance boon, great bonus!