AnimatGuiCtrls.Network.IcmpPacket.ToUInt16Array C# (CSharp) Method

ToUInt16Array() public method

Converts ICMP packet to UInt16 array
public ToUInt16Array ( ) : System.UInt16[]
return System.UInt16[]
        public UInt16[] ToUInt16Array()
        {
            //Get the Half size of the Packet
            int checksumBufferLength = (int)Math.Ceiling((double)ICMP_PACKET_SIZE / 2);

            //Create byte array
            byte[] buffer = this.ToByteArray();
            if (buffer == null)
                return null;

            //Create a UInt16 Array
            UInt16[] checksumBuffer = new UInt16[checksumBufferLength];

            //Code to initialize the Uint16 array
            int icmpHeaderBufferIndex = 0;
            for (int i = 0; i < checksumBufferLength; i++)
            {
                checksumBuffer[i] = BitConverter.ToUInt16(buffer, icmpHeaderBufferIndex);
                icmpHeaderBufferIndex += 2;
            }

            return checksumBuffer;
        }