I am trying to understand double[…] list better.
After using different ways of typing I cannot figure out what I am doing wrong
I hope it is a typing error but I cannot find it.
The code is based on a past post of someone else.
1.By resizing, do you know if it takes more memory as like with the List<double> situation wherein every number you add costs memory, doing sequence.Resize?
2.When looking to the examples you gave me, the following of the correct code you gave me is not yet clear to me. So, I understand max + 1 makes a list length of for example 5 + 1 but why you put an (int) in it? Because index-numbers/items can only be 0,1,2,3,4,5 right
double sequence = new double[(int) max + 1];
The notation (int) is new for me, I now know, it has to be written like that, but if it is something typical and I have to remember it for somewhere else in the future, hmmm
3.Is (int) a typical/familiar thing?
No, no, no, do not use ArrayList. That’s a leftover collection type from .NET 1.0 when they didn’t support genetics yet. Use either List<T> or T. If you don’t know how many items you’re going to add you can use list, or if you need a shared collection which changes over time. However I’d recommend using arrays as often as possible. Arrays are pretty stark and limited, but that actually helps you really think deeply about your algorithm.