Recent Posts
Calendar
June 2008
S M T W T F S
« May   Jul »
1234567
891011121314
15161718192021
22232425262728
2930  

Archive for June 23rd, 2008

Why you can’t cast an integer to a string.

I saw this question last Thursday on Channel 9 that I’ve heard before. My guess is that there are enough people who have the same question that it’s worth addressing.

I know there’s probably a really good reason for this, but I can’t think of what it is, and it keeps bugging me. Why can’t you do
int x = 10;
string y = (string)x;
in C#? I mean, you could simply use x.ToString(), but why doesn’t the explicit cast do the same?

Read the rest of this entry »