Hi all,
it's possible to return, from a method, an anonymous type list?
I build my list of anonymoust type like this var l = (new[] { new { Name = "thename", Age = 30 } }).ToList();
Thanks
Hi all,
it's possible to return, from a method, an anonymous type list?
I build my list of anonymoust type like this var l = (new[] { new { Name = "thename", Age = 30 } }).ToList();
Thanks
It is possible if you return list that was cast to object
, but it is useless. Consider creating class with corresponding fields instead of anonymous class.
It is possible, at a pinch, it's rather humourously called 'mumbling'.
This involves passing in a prototype of your anonymous type as a generic variable. Remembering that two anonymous types are considered to be the same type if they have the same named/typed properties in the same order.
I have write this method: List Cast(object o, T type) { return (List)o; }
and the method that should return a anonnymous type list, now return an object and i cast, with Cast method, to what i need.
it is a tricky method, but is does what i need for now.
thanks to all