2

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!

1
  • rep win for anyone who answered this question within the first minute :P Commented Jul 24, 2009 at 18:58

8 Answers 8

12

Change buffer(i) to buffer[i]

Sign up to request clarification or add additional context in comments.

4 Comments

Dammit! Beat me by seconds! +1
More like the Beat Jon Skeet effect.
@Matthew Jones: yeah, except he gets more rep than you even if he answers the question 10 days after it was posted. He transcends quickness.
If you have five answers and Jon Skeet has five answers, Jon Skeet has more rep than you.
10

Change buffer(i) to buffer[i] as VB array descriptors are () and C# array descriptors are [].

Comments

7

Use brackets instead of parentheses.

iLookup = (crc32Result & 0xff) ^ buffer[i];

Comments

5
buffer[i];  //not buffer(i)

you used parenthesis instead of brackets.

Comments

5

You need square brackets instead of round ones at the end of the second line.

^ buffer[i];

Comments

5

You want to change the () to []. Array indexing in C# is done using square brackets, not parentheses.

So

iLookup = (crc32Result & 0xff) ^ buffer[i];

Comments

5

it should be

iLookup = (crc32Result & 0xff) ^ buffer**[i]**

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.