2012-09-17 25 views
3

我有一行用C#編寫的代碼,需要轉換爲Vb.Net。將GetBytes C#行轉換爲VB.Net

在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); 

這條線的正確轉換是什麼?

感謝

+0

[C#to VB](http://converter.telerik.com/)轉換器。 – Magnus

回答

5

這將使用Not在VB.Net進行按位否定:

comp.Write(BitConverter.GetBytes(CUShort(Not length)), 0, 2)