Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

struct - what is it for?

Tags:

c#

struct

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?

like image 884
lak-b Avatar asked Dec 28 '09 18:12

lak-b


1 Answers

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.

like image 142
jason Avatar answered Sep 22 '22 23:09

jason