Name
, each instance of
FixedBankRecord
will contain all 80
bytes of the
Name
array, which is the way that a C++
struct
would be organized. Thus, the
overall size of
FixedBankRecord
is 96, which is the sum of its members. Here is a program
that demonstrates this fact:
// Demonstrate a fixed-size buffer.
using System;
// Create a fixed-size buffer.
unsafe struct FixedBankRecord {
public fixed byte Name[80]; // create a fixed-size buffer
public double Balance;
public long ID;
}
class FixedSizeBuffer {
// Mark Main as unsafe.
unsafe static void Main() {
Console.WriteLine("Size of FixedBankRecord is " +
sizeof(FixedBankRecord));
}
}
The output is shown here:
Size of FixedBankRecord is 96
www.freepdf-books.com
598
P a r t I :
T h e C # L a n g u a g e
Although the size of
Do'stlaringiz bilan baham: |