title: generic method - call method different class
body: <p>I would like to set to variable result method from first class or second class which depend from type, what is wrong in my code??</p>
  
  <pre><code>    public ActionResult Contact()
      {
          ViewBag.Message = GetValue(new ClassOne(), "classOne");
  
          return View();
      }
  
  
  
      public string GetValue&lt;T&gt;(T customClass, string type)
      {
          if (type == "classOne") return customClass.ClassOneMethod();
          else customClass.ClassTwoMethod();
      }
  
      class ClassOne
      {
          public string ClassOneMethod()
          {
              return "ClassOneMethod";
          }
      }
  
      class ClassTwo
      {
          public string ClassTwoMethod()
          {
              return "ClassTwoMethod";
          }
      }
  </code></pre>