| ■No82438 (ぎゅんぎゅ さん) に返信 > Public Function Append(ByVal crc As UInteger, ByVal input As Byte(), ByVal offset As Integer, ByVal length As Integer) As UInteger VB には「Input 関数」が存在するので、input という引数名ではなく、別の名前にした方が良いですね。 予約語ではないので、この名前のままでもエラーにはなりませんけれども。
>> crcLocal = table[(crcLocal ^ input[offset++]) & 0xff] ^ crcLocal >> 8; > crcLocal = table((crcLocal Xor input(System.Math.Max(System.Threading.Interlocked.Increment(offset), offset - 1))) And &HFF) Xor crcLocal >> 8
C# の「offset++」と VB の「System.Math.Max(System.Threading.Interlocked.Increment(offset), offset - 1)」は 等価では無いので、ここは修正が必要ですね。
下記の C# コードは、「33」「44」を出力します。
int[] ary = new int[] { 11, 22, 33, 44, 55 }; int offset = 2; Console.WriteLine(ary[offset++]); Console.WriteLine(ary[offset++]);
下記の VB コードは、「44」「55」です。
Dim ary As Integer() = New Integer() {11, 22, 33, 44, 55} Dim offset As Integer = 2 Console.WriteLine(ary(System.Math.Max(System.Threading.Interlocked.Increment(offset), offset - 1))) Console.WriteLine(ary(System.Math.Max(System.Threading.Interlocked.Increment(offset), offset - 1)))
> Public Sub New() > #If Not NETCORE Then > #End If > HashSizeValue = 32 > End Sub
この部分、元の C# コードに合わせるなら
Public Sub New() #If Not NETCORE Then HashSizeValue = 32 #End If End Sub
ではありませんか?
> しかし、実行しても、 > エラーは出ないのですが、0しか返しません。 > なにが原因でしょうか?
先のインクリメント部分を直してみてください。 それと、このコードをどのようにして呼び出していますか?
> でエラーが出たので > それぞれ以下のように変更しました
この誤訳は SharpDevelop の問題っぽいですね。 |