c#.netでの型キャストについて知りたいのですが、以下のコード行があります。
int i=4
object o = i // This works properly without any typecasting becausing boxing takes place automatically
string s= i // This does not work, even when the string is also reference type?
string s=(string)i //This also does not work even if i try to typecast the int to string.
string s= Convert.ToString(i); // this works.
だから私はなぜstring s = i and string s = (string)i
うまくいかないのか、そして使用の違いは何なのか知りたいです(string)i, i.ToString(), and Convert.ToString(i)
。