C#的加減乘除
看板C_Sharp (C#)作者ithinkurdumb (YANKEES RULE ALL!)時間20年前 (2004/10/14 18:58)推噓0(0推 0噓 0→)留言0則, 0人參與討論串1/4 (看更多)
發現一個現象,
我在VS.NET 2003 / VS 2005裡面,
沒辦法對兩個非Int32作四則運算.
也就是說像
Int16 MyInt1 = 10;
Int16 MyInt2 = 20;
Int16 MyInt3 = MyInt1 + MyInt2;
compile的時候會出現一個error,
"Cannot implicitly convert type 'int' to 'short'".
另外當我把一個double的值assign給一個int的時候,
VC++會給一個warning說可能會lose data.
但是在C#之中就會是一個error了.
請問一下有什麼solution嗎?
Thx...:)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 210.68.184.96
討論串 (同標題文章)
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章
21
65