by Merad · 5y ago · 0 comments
In C# structs are value types, and they've been with .Net since the beginning IIRC. I assume maybe you're referring to System.ValueTuple? It was added in C# 7 and allowed tuples to be value types along with significantly better syntax for working with them.
- proper memory slices
- ability to do stackalloc in safe code
- readonly structs
- generics for blittable types
- zero allocation pipelines
- using without IDispose for structs without implicit boxing
- return scope for zero copy struct parameters
- native function pointers
- static lambdas
I would agree that things like
> - using without IDispose for structs without implicit boxing
and
> - generics for blittable types
would make value types more "proper" in the C# language.
Just like C and C++ offer similar optimizations to avoid writing the tons of Assembly that was so common up to the mid-90's.
So yes, optimizations are definitly part of proper value types.
There is so much more for value type programming, see sibling comment.
[0] https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/exp...