Why does this:
System.Collections.Stack s = new Stack();
s.Push(97);
char c = (char) s.Pop(); //throws InvalidCastException
throw an error, but this:
char c = (char) 97; //c = 'a'
work just fine?
I'm especially confused since s.Pop().GetType()
returns System.Int32
, so it really shouldn't matter...
What's going on here? Am I missing something, or do I have to work around it?