The optimal solution for a structure with more than 16 bytes

I have a type that I consider used as a struct.

  • It represents one meaning
  • It is unchanging

But the problem is that it has 6 int fields.

So what solution should I use for this type?

  • keep using struct?
  • change class
  • or a packet of 6 integers into an int array, so it has only one field

EDIT

The size of the structure with 6 integer fields is 24 bytes, which is very important for traversal. Recommended size for structure not more than 16 bytes

+3
source share
7 answers

It depends on how you are going to use it?

  • , ?
  • ? .
  • struct vs. class? , -nullable?
  • , ? String.Empty. .

, .

+5

. , , , .

, .

(# 2), .

(# 3), , . int .

+1

, - . , .

0

WriteOnce<int[]>?

0

, , . ( ).

( , .)

0

, , , , . TwentyFourByteStruct [1000], 24 000 , , , - . TwentyFourByteClass [1000], 4000 8000 ( 32/64- ), TwentyFourByteClass, , 48 . TwentyFourByteClass, 4 048 8 048 . TwentyFourByteClass, 52 000 56 000 .

, , , , . , 16 (.net 16 ), , 1 16 000 .

0

, , . , .

-1

All Articles