+ 2
Why structures in C#?
Structures in C# are almost the same thing as class. In structures does not make any sense to me having a structures that have methods and also a constructor like a class. For me that is insane. Can you give me a example of that aplication and make a more deep differentiation between the structure and the class in C#. Not even in C that kind of thing in structures are allow.
1 Respuesta
+ 4
Werg Serium there is a performance difference. I think the primary thing to understand about structs in C# is described very well in ChatGPT's words:
"Structs are value types and are stored directly where they are declared, which can result in less memory overhead compared to classes."
ChatGPT gave me five other differences that would help determine when a struct is more appropriate than a class. It is too long to paste here.