ReadString() public static méthode

public static ReadString ( BinaryReader br, int len ) : string
br System.IO.BinaryReader
len int
Résultat string
        int DisptachPacket(byte[] packet, long size)
        {
            MemoryStream stream = new MemoryStream(packet);
            BinaryReader br     = new BinaryReader(stream);

            int bytesConsumed = 0;

            while (stream.Position + 24 < size)
            {
                uint   networkID = br.ReadUInt32();
                string packetID  = Program.ReadString(br, 12);
                uint   length    = br.ReadUInt32();
                uint   checksum  = br.ReadUInt32();
                if (stream.Position + length > size)
                {
                    break;
                }

                Console.WriteLine(packetID);

                if (networkID == mNetworkID)
                {
                    byte[] payload = br.ReadBytes((int)length);

                    byte[] hash = Program.GenerateHash(payload);
                    if (CompareChecksum(checksum, hash))
                    {
                        // valid packet, get the handler
                        if (mPacketProcessors.ContainsKey(packetID))
                        {
                            PacketProcessor p = mPacketProcessors[packetID];
                            p(payload);
                        }
                        else
                        {
                            Console.WriteLine("Unhandled packet: " + packetID);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Failed checksum!");
                    }
                }
                else
                {
                    Console.WriteLine("Failed ID Check, Network ID: " + networkID);
                }

                bytesConsumed += 24 + (int)length;
            }

            br.Close();
            return(bytesConsumed);
        }
        void PH_Alert(byte[] payload)
        {
            MemoryStream stream = new MemoryStream(payload);
            BinaryReader br     = new BinaryReader(stream);
            UInt64       msgLen = Program.ReadVarInt(br);
            string       msg    = Program.ReadString(br, (int)msgLen);
            UInt64       sigLen = Program.ReadVarInt(br);
            string       sig    = Program.ReadString(br, (int)sigLen);

            Console.WriteLine("Alert: " + msg + " from: " + sig);
            br.Close();
        }