2

I have an object in vbs:

 Msgbox myobject.parametro("parm")

I can use it in C# in this way:

Object test = myobject.GetType().InvokeMember("parametro", 
    BindingFlags.GetProperty, 
    null, 
    myobject, 
    new object[] { "parm" });

Messagebox.show(test.toString());

How can I in C# assign a value to the property?

For example:

myobject.parametro("parm")=725
Eugene Podskal
  • 10,270
  • 5
  • 31
  • 53
  • what is `parametro`, and how is it declared? if you show us *what that is*, we can probably indicate how to invoke it properly – Marc Gravell Oct 07 '14 at 11:12

2 Answers2

1

I think you mean:

myObject.parametro["parm"] = 627; // set
var test = myObject.parametro["parm"]; // get
Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
0

Change BindingFlags to SetProperty

SomeClass c = new SomeClass();
c.GetType().InvokeMember("Prop", BindingFlags.SetProperty, null, c, new object[]{ 1 });
lucas
  • 1