I have a program ported from VB6 to C #. It controls various equipment in an industrial environment, so it must create and calculate the length in bytes of messages sent to the hardware. These messages are created from structures consisting of many primitive data types.
The original VB6 code is widely used by LenB. I am thinking of using System.Runtime.InteropServices.Marshal.SizeOf () instead. Is this a good choice to replace LenB?
In addition, the source program used several LenB places on the same line, for example
inputlen = LenB(sequenceBytes) - LenB(headerBytes) - LenB(crcBytes)
Replacing each of them with "system.Runtime.InteropServices.Marshal.SizeOf" will result in a long, hard to read line. C # doesn't have preprocessor macros, so is there a way to use the using statement or something to eliminate all of these qualifiers in order to shorten the string? Or just write a method?
source
share