0
struct vs class
I have a program with a dictionary of objects. During runtime anywhere from 400 to 500 objects are in the dictionary. The objects are largely a group of simple data types, but are over 16 bytes and get updated/modified on a continuous basis. They never need to be boxed. Should I use structs or classes? What are the advantages of each?
2 ответов
0
I realize that what I really need to do is write both and do performance testing.
0
Those four qualifications come from Microsoft, but Microsoft is not internally consistent with sticking to those guidelines. For example (from the same SO post) the Entry of the Dictionary class is a struct. I was wondering really if anyone has performance data on structs violating only 2 and 3 of the above. Again, I'm likely going to have to do performance testing myself. I also might be better off with a SortedList instead of a Dictionary. Again will need to do testing.