Friday, 14 December 2018

c# - struct - what is it for?



I know something about struct type. But I can't understand: what is it for? when have I use it? Classes, simple value-types and enums - that's all that I need.




Any suggestions?



UPD: PLEASE! Don't tell me that struct is in the stack (I know this :). What struct is for?


Answer



You choose a struct if you want value-type semantics. You choose a class if you want reference-type semantics. All other concerns are secondary to this one.


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...