Array resizing issues
I'm so lost, i've been trying to resize my array
Here's the code
However, whenever i try to set a higher index using Set, it throws an index out of bounds exception
18 Replies
I tried using Array.CopyTo and then value = the array given by CopyTo, but nothing works
Use the debugger to see what the values are after resizing?
Resizing seems to work fine on my end
Stupid question, but, why not use
List
instead?You can't set list items at arbitrary indexes, the above is probably supposed to allow setting the 8376th element of a 3-element array
I guess depending how large the gaps are supposed to be, though, I would maybe consider a dictionary though
yup
theyre not that drastic but i've found out this is much more performance efficient in my scenario
atleast in my java iteration of this project, havent tested the c# one but im guessing it'd be similar
Or giving the member an
Id
property to access the object
directly?im far less familiar with the toolchain in the language to be able to do this
This is used as a registry
It's nothing complex. Set a breakpoint, run the debug, watch the values
$debug if you want a full tutorial
Tutorial: Debug C# code and inspect data - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
I dont particularly know what id will be set up until the startup of the project
Thank you very much
So it is possible that you'll end up with large gaps? If so, then I would really just consider a dictionary
welp the debuggger has spewed a LOT of stuff i do not understand
Like what?
Kinda everything
it's intimidating at first
Might just end up doing this
Seeing how the name of this class says "single thread", I assume some threading is involved somewhere. There's also a
ConcurrentDictionary
that's thread-safe, should you need ityup there's one thats volatile and locked and one that's just plain old array without anything to synchroizeit