Help example does not compile

  • Thread starter Thread starter Waldy
  • Start date Start date
W

Waldy

Hi there,
the help for InvokeMember shows an example that will not compile:

typeof(C).InvokeMember("F", BindingFlags.SetField, null, C, new
Object{"strings new value"});

The error message is:

A new expression requires () or [] after type
 
The error message is is spot on in this case, the line should be:

typeof(C).InvokeMember("F", BindingFlags.SetField, null, C, new Object
[]{"strings new value"});
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top