title: Is there a way to return Anonymous Type from method?
body: <p>I know I can't write a method like:</p>
  
  <pre><code>public var MyMethod()
  {
     return new{ Property1 = "test", Property2="test"};
  }
  </code></pre>
  
  <p>I can do it otherwise:</p>
  
  <pre><code>public object MyMethod()
  {
     return new{ Property1 = "test", Property2="test"}
  }
  </code></pre>
  
  <p>but I don't want to do the second option because, if I do so, I will have to use reflection.</p>
  
  <hr />
  
  <p>Why I want to do that:</p>
  
  <p>Today i have a method inside my aspx page that returns a datatable as result and I <strong>cannot change it</strong>, I was trying to convert this DataTable to an Anonymous method with the properties that I want to work with. I didn't want to create a class only to do that and as I will need to perform the same query more than one time, I Thought to create a method that returns an anonymous type would be a good ideia.</p>