FixedBankRecord
is the exact sum of its members, this may not be
the case for all
struct
s that have fixed-size buffers. C# is free to pad the overall length of
structure so that it aligns on an even boundary (such as a word boundary) for efficiency
reasons. Therefore, the overall length of a
struct
might be a few bytes greater than the sum
of its fields, even when fixed-size buffers are used. In most cases, an equivalent C++
struct
would also use the same padding. However, be aware that a difference in this regard may
be possible.
One last point: In the program, notice how the fixed-size buffer for
Name
is created:
public fixed byte Name[80]; // create a fixed-size buffer
Pay special attention to how the dimension of the array is specified. The brackets containing
the array size follow the array name. This is C++-style syntax, and it differs from normal C#
array declarations. This statement allocates 80 bytes of storage within each
Do'stlaringiz bilan baham: |