PacketHeader
is a good choice for a
struct
because it contains only a small amount of data
and does not use inheritance or even contain methods. As a structure,
does
not incur the additional overhead of a reference, as a class would. Thus, any type of
transaction record can use
PacketHeader
without affecting its efficiency.
As a point of interest, C++ also has structures and uses the
struct
keyword. However,
C# and C++ structures are not the same. In C++,
struct
defines a class type. Thus, in C++,
struct
and
class
are nearly equivalent. (The difference has to do with the default access of
their members, which is private for
class
and public for
Do'stlaringiz bilan baham: |