Anonymous Object Creation

This approach is nothing new, I’m simply putting this here as a note to myself.

When returning a particular object, it is possible to create an instance of the object anonymously. That is – you have not assigned a name to this particular object. You just passed it directly out of the method.

public object GetKitchenObjects()
   return new {
         owner = “Jack”,
         items = new List(“pot”, “pan”)