Reputation: 12560
I have a CRC class written in VB.NET. I need it in C#. I used an online converter to get me started, but I am getting some errors.
byte[] buffer = new byte[BUFFER_SIZE];
iLookup = (crc32Result & 0xff) ^ buffer(i);
On that line, the compiler gives me this error:
Compiler Error Message: CS0118: 'buffer' is a 'variable' but is used like a 'method'
Any ideas how I could fix this?
Thanks!
Upvotes: 2
Views: 229
Reputation: 2204
I assume there are some lines missing between these two? Otherwise, you are always going to be doing an XOR with zero...
"buffer" is a byte array, and is accessed with the square brackets in C#. "buffer(i);" looks to the C# compiler like a method call, and it knows you have declared it as a variable. Try "buffer[i];" instead.
Upvotes: 0
Reputation: 614
Change buffer(i) to buffer[i] as VB array descriptors are () and C# array descriptors are [].
Upvotes: 10
Reputation: 4470
You want to change the () to []. Array indexing in C# is done using square brackets, not parentheses.
So
iLookup = (crc32Result & 0xff) ^ buffer[i];
Upvotes: 5
Reputation: 5553
You need square brackets instead of round ones at the end of the second line.
^ buffer[i];
Upvotes: 5
Reputation: 29722
buffer[i]; //not buffer(i)
you used parenthesis instead of brackets.
Upvotes: 5
Reputation: 26190
Use brackets instead of parentheses.
iLookup = (crc32Result & 0xff) ^ buffer[i];
Upvotes: 7