4

Vb.Netに変換する必要があるC#で記述されたコード行があります。

C#では

私はこのブロックを持っています...

// Calculate number of 64K blocks
  uint          rowsPerBlock = _MAXBLOCK/widthLength;
  uint          blockSize = rowsPerBlock*widthLength;
  uint          blockCount;
  ushort        length;
  uint          remainder=dcSize;

その後、長さ変数に値が割り当てられ、他の計算に使用されます

length = (ushort)((remainder < blockSize) ? remainder : blockSize);

    if (length == remainder)
    {
      comp.WriteByte(0x01);
    }
    else
    {
      comp.WriteByte(0x00);
    }

    comp.Write(BitConverter.GetBytes(length), 0, 2);

    // Write one's compliment of LEN

次の行を除いて、上記のすべてを変換しました。

comp.Write(BitConverter.GetBytes((ushort)~length), 0, 2);

この行の正しい変換は何でしょうか?

ありがとう

4

2 に答える 2

5

これはNot、VB.Netでビット単位の否定を実行するために使用されます。

comp.Write(BitConverter.GetBytes(CUShort(Not length)), 0, 2)
于 2012-09-17T18:14:59.333 に答える
1

このコードで試すことができます

Dim byteArray As Byte( ) = BitConverter.GetBytes( (CUShort)Not length)
comp.Write(byteArray , 0, 2);

リンクBitConverter.GetBytes: http: //msdn.microsoft.com/fr-fr/library/vstudio/fk3sts66.aspx#Y0

リンクではありません:http://msdn.microsoft.com/fr-fr/library/2cwcswt4%28v=vs.80%29.aspx

于 2012-09-17T18:15:17.410 に答える