Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trouble with casting
Message
 
To
23/09/2014 12:52:13
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01608054
Message ID:
01608079
Views:
21
>
>Adding two ints could overflow to a long, so that probably isn't a good argument. Based on http://stackoverflow.com/questions/11853602/c-sharp-does-not-let-me-sum-two-shorts-to-a-short, it looks like there is no + operator assigned for shorts, so they get promoted to ints, and the result is therefore an int.

I like that answer better <g> - yeah, I assumed the compiler was doing some overflow checking with the Convert call, since having the compiler do that anywhere else would make it difficult to do basic math.
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Reply
Map
View

Click here to load this message in the networking platform