i have a requirement to set the property to a client application from the dll referenced.
the technical part explained below.
i have a class instance
public class test { public string Resultobj; public string Result { get { return Resultobj; } set { Resultobj = value; } } test obj = new test(); } I am sending this to a method as a parameter which resides in another assembly.
callmethod(test obj ); so in the referenced assembly i need to set the values to the instance so that it can be accessed from the application. Can anyone provides suggestion on how to set properties to a class instance that passed as a parameter to a method.
Here I am adding what i tried but its wrong. :-(
public override void callmethod(ref object obj) { Type type = Type.GetType(obj); PropertyInfo property = type.GetProperty("Result"); property.SetValue(type , "somevalue", null); } Since the class name instance will be pass at runtime I can not provide the class name as datatype. I'm getting error in the line
callmethod(test obj ); Argument '1': cannot convert from 'test ' to 'ref object'
its wrongref, and it doesn't need to beobject.public void callmethod(test t) { t.Result = "somevalue"; }