✅ How do I set a struct attribute to its parameter name?
Doing this doesn't work.
I'm looking for something like a dataclass that just holds attributes I set once and read off continuously.
Looking for something like this:
And then to be able to add a bunch to an array:
20 Replies
this.id = id;
that it?
Yeah, assuming your example is correct
Oh uh
what about for the array
Data class would be record
ooh whats that
and is struct fine or should i use record
Your struct is mutable
i literally just want something to hold a group of attributes that i can access later on, thats it
Records are not
Then record should be your default
so records are set once, cant set again?
Yes
awesome
also how do you close threads?
$close
If you have no further questions, please use /close to mark the forum thread as answered
cheers
oh wait
$records
Use record types tutorial - C#
Learn about how to use record types, build hierarchies of records, and when to choose records over classes.
In case you wanna read a out it
:thumbsup:
And for the array...
Exanple[] x = [new(1, "hello")];