title: how to pass a class instance as a parameter to a method in c#
body: <p>i have a requirement to set the property to a client application from the dll referenced.</p>
  
  <p>the technical part explained below.</p>
  
  <p>i have a class instance</p>
  
  <pre><code>public class test
  {
      public string Resultobj;
      public string Result
      {
          get
          {
              return Resultobj;
          }
          set
          {
              Resultobj = value;
          }
      }
      test obj = new test();
  }
  </code></pre>
  
  <p>I am sending this to a method as a parameter which resides in another assembly.</p>
  
  <pre><code>callmethod(test obj );
  </code></pre>
  
  <p>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.</p>
  
  <p>Here I am adding what i tried but its wrong. :-(</p>
  
  <pre><code>public override void callmethod(ref object obj)
  {
      Type type = Type.GetType(obj);
      PropertyInfo property = type.GetProperty("Result");
      property.SetValue(type , "somevalue", null);
  }
  </code></pre>
  
  <p>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</p>
  
  <pre><code>   callmethod(test obj );
  
  Argument '1': cannot convert from 'test ' to 'ref object'
  </code></pre>