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 User10mo ago
Message Not Public
Sign In & Join Server To View
Jimmacle
Jimmacle10mo 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
UvuvwevweOnyetenyeOP10mo ago
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
Jimmacle10mo 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
UvuvwevweOnyetenyeOP10mo ago
i c so would i have a list of lists of neurons
Jimmacle
Jimmacle10mo ago
yes
UvuvwevweOnyetenye
UvuvwevweOnyetenyeOP10mo ago
aight bet
Jimmacle
Jimmacle10mo ago
lists are essentially arrays but they automatically get bigger when you add items
UvuvwevweOnyetenye
UvuvwevweOnyetenyeOP10mo ago
c++ equiv of vector
Jimmacle
Jimmacle10mo ago
yeah
UvuvwevweOnyetenye
UvuvwevweOnyetenyeOP10mo ago
and then arrays are basically the same between c# and c++ at least in application dubs
i like chatgpt
i like chatgpt10mo 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
Jimmacle10mo ago
it would be a more realistic comparison to use pointers and C# references are more like pointers than stack allocated variables
Want results from more Discord servers?
Add your server