Array exception

I can't for the life of me figure out this exception. ive identified that it comes from neurons because of it not actually appending the jagged array. Im sure this is something im misunderstanding with C#, maybe something with ownership?
No description
No description
13 Replies
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Jimmacle
Jimmacle5mo ago
what you're missing is .Append doesn't mutate the source collection, it produces an enumerable that represents the contents of that collection with the appended item at the end C# arrays can't be resized automatically, if you want that behavior use Lists with .Add instead
UvuvwevweOnyetenye
im translating that ot mean its something like python, where 99.9% of functions to change things return the changed value that you then set the original variable equal to
Jimmacle
Jimmacle5mo ago
in this specific case with .Append, yes that method is part of LINQ which is a collection of functions to filter/map collections
UvuvwevweOnyetenye
i c so would i have a list of lists of neurons
Jimmacle
Jimmacle5mo ago
yes
UvuvwevweOnyetenye
aight bet
Jimmacle
Jimmacle5mo ago
lists are essentially arrays but they automatically get bigger when you add items
UvuvwevweOnyetenye
c++ equiv of vector
Jimmacle
Jimmacle5mo ago
yeah
UvuvwevweOnyetenye
and then arrays are basically the same between c# and c++ at least in application dubs
i like chatgpt
i like chatgpt5mo ago
In C++, array cannot be assigned directly to another array.
// c++
int p[] = { 1,2 };
int q[2];
// q = p; // Error
memcpy(q, p, sizeof(p));
// c++
int p[] = { 1,2 };
int q[2];
// q = p; // Error
memcpy(q, p, sizeof(p));
But in C#, it is ok.
// c#
int[] p = {1, 2};
int[] q = p;
// c#
int[] p = {1, 2};
int[] q = p;
Jimmacle
Jimmacle5mo ago
it would be a more realistic comparison to use pointers and C# references are more like pointers than stack allocated variables