0

I'm writing some codes that uses reflection, but I realized array of types behave somewhat surprisingly.

When I try to create an array the normal way, like this:

Type[] params = new Type[2];

I receive an error saying

Class name is not valid at this point

Why is it saying that? How is Type different from the other types?

1
  • 2
    Arrays of Type behave just like any other array; replace Type with string or anything else, and you'll see the same error message. Commented Jul 18, 2014 at 8:10

1 Answer 1

13

That has nothing to do with the fact that it is an array of Type. It's because params is a keyword. Either escape the name (which is done by prefixing it with an @ symbol) or use a different name.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.