Ken,
> What facilities are available in VB.Met and C# (which does not have
> pointers, which made this so easy, albeit error prone, in C and C++)?
Personally that is the key word "error prone"! .NET goes out of its way to
avoid such error prone code!
> One of the drawbacks with VB6 and earlier was the difficulty in casting a
> 'record' to a different 'shape' so one could perform different
manipulations
> on it.
Luckily VB6 & VB.NET have type safety! I consider this a major benefit not a
drawback!
Note a VB6 Type is a VB.NET Structure, however I would recommend using a
Class instead.
> I have a complex data structure, which I can represent
> in a VB6 TYPE declaration, but I cannot easily convert that to a fixed
> length array of unsigned bytes so that I could perform a checksum
> calculation on the contents.
I would "serialize" the structure to a MemoryStream using a BinaryWriter. I
would then calculate the checksum on the MemoryStream. Both MemoryStream &
BinaryWriter are in the System.IO namespace. Alternatively you can use
System.GitConverter.GetBytes to get byte arrays for individual members
however the BinaryWriter & MemoryStream makes this significantly easier!
> Another case is where a read a buffer from a
> file and then wish to interpret the contents based on some header
> information.
I would use an BinaryReader to read the header information interpreting &
"deserializing" as I go. BinaryReader is also in the System.IO namespace.
By "serialize" and "deserialize" I mean I would implement custom routines
that would convert an object to & from a binary format using the
BinaryReader & BinaryWriter classes similar to what is described in the
following article:
http://msdn.microsoft.com/library/de...rp09182003.asp
Note the samples are C#, with your C++ background you should be able to
convert them.
An alternative to the BinaryReader & BinaryWriter is the
System.Runtime.InteropSerivces.Marshal class. Check out the StructureToPtr &
PtrToStructure methods along with the Copy or Read methods. Although the
method is StructureToPtr you can use them with either a VB.NET Class or a
Structure...
Hope this helps
Jay
"Ken Allen" <(E-Mail Removed)> wrote in message
news:ee%23xkA%(E-Mail Removed)...
> I am relatively new to .Net, but have been using VB and C/C++ for years.
>
> One of the drawbacks with VB6 and earlier was the difficulty in casting a
> 'record' to a different 'shape' so one could perform different
manipulations
> on it. For example, I have a complex data structure, which I can represent
> in a VB6 TYPE declaration, but I cannot easily convert that to a fixed
> length array of unsigned bytes so that I could perform a checksum
> calculation on the contents. Another case is where a read a buffer from a
> file and then wish to interpret the contents based on some header
> information. This was also very difficult in VB6.
>
> What facilities are available in VB.Met and C# (which does not have
> pointers, which made this so easy, albeit error prone, in C and C++)?
>
> -Ken
>
>