Is it possible to create an object without a class in C#?
Anonymous Types is what you looking for. Eg -
var v = new { Amount = 108, Message = "Hello" };
Above code will create a new object
with properties Amount
and Message
.
Yes there is ExpandoObject
under System.Dynamic
namespace.You could add properties on the fly like you do in other dynamic languages
dynamic dynObject = new ExpandoObject();
dynObject.someProperty= "Value";
http://msdn.microsoft.com/en-us/library/system.dynamic.expandoobject.aspx