C# -Interview Question Anonymous Type
- by Amutha
Recently i was asked to prove the power of C# 3.0 in a single line( might be tricky)
i wrote
new int[] { 1, 2, 3 }.Union(new int[]{10,23,45}).
ToList().ForEach(x => Console.WriteLine(x));
and explained you can have (i) anonymous array (ii) extension method (iii)lambda and closure all in a single line.I got spot offer.
But.....
The interviewer asked me how will you convert an anonymous type into know type :(
I am 100% sure ,we can not do that.The interviewer replied there is 200% chance to do that
if you have a small work around.I was clueless.
As usual,I am waiting for your valuable reply(Is it possible?).