Posts

Showing posts from October, 2011

C# Polymorphic types conversion with Generics

Image
Polymorphism has been interviewer's  delight for ages. I have been taking interviews for quite some time.  And ever since i started preparing question on C# Polymormism, I have been getting surprises. To prepare interview questions, I try writing code, verify it and and then twist the code snippet to make it "interview-able".
This blog is to highlight some of the surprises that i have got while preparing the questions.  The motive of this blog is to highlight tricky points to keep in mind while writing overloaded Functions with Generic parameter. To explain the concept, I'll start with this short code snippet and would like readers to predict the output without scrolling down to answer.
































If you know the output and the reasoning behind it, then you may leave the rest of blog as you probably are better expert than rest of my audience.  And if you are still reading this line it means you are searching for the answer. You will definately get to know the answer, but befor…