title: How To Pass Different Objects to same Function in C#
body: <p>I have 10 different classes, but below are two for the purpose of this question :</p>
  
  <pre><code>public class Car
  {
      public int CarId {get;set;}
      public string Name {get;set;}
  }
  
  public class Lorry
  {
      public int LorryId {get;set;}
      public string Name {get;set;}
  }
  </code></pre>
  
  <p>Now I have a function like</p>
  
  <pre><code>public static object MyFunction(object oObject, string sJson)
  {
      //do something with the object like below 
      List&lt;oObject&gt; oTempObject= new List&lt;oObject&gt;();
      oTempObject = JsonConvert.DeserializeObject&lt;List&lt;oObject&gt;&gt;(sJson);
      return oTempObject;
  }
  </code></pre>
  
  <p>What I'm wanting to do is pass the object I create like (oCar) below to the function.</p>
  
  <pre><code>Car oCar = new Car();
  </code></pre>
  
  <p>My question is how can I pass a object of a different type to the same function ?</p>