3 ms·
In the context of C# this becomes a real pain. The isuee are arrays/lists. Because in C# an int[] array or List<int> is a reference. So even if you put a int
by OneGuy123 6y ago
In the context of C# this becomes a real pain.
The isuee are arrays/lists.
Because in C# an int[] array or List<int> is a reference.
So even if you put a int[] in a struct this int[] will NOT be copied when you assign an instance of this struct to another instance: you will get a reference share which makes this annoying since you cannot do a proper deep copy with the language itself: you are forced to use reference copy instead of deep copy.
In C++ this is easy because the types differentiate between pointer and non-pointer explicitly + you can overload the assignment operator.
- pjmlp 6y agoUnless one uses a struct based array instead. https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/unsafe-code-pointers/fixed-size-buffers https://docs.microsoft.com/en-us/dotnet/csharp/programming-g... https://docs.microsoft.com/en-us/dotnet/api/system.memory-1?view=netcore-3.1 https://docs.microsoft.com/en-us/dotnet/api/system.memory-1?...