What is the difference between casting and conversion?

Joel Spolsky picture Joel Spolsky · Jul 2, 2010 · Viewed 17.5k times · Source

Eric Lippert's comments in this question have left me thoroughly confused. What is the difference between casting and conversion in C#?

Answer

chrissr picture chrissr · Jul 2, 2010

Casting is a way of telling the compiler "Object X is really Type Y, go ahead and treat it as such."

Conversion is saying "I know Object X isn't Type Y, but there exists a way of creating a new Object from X of Type Y, go ahead and do it."