Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trouble with casting
Message
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Trouble with casting
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:
01608054
Views:
61
Hi everybody,

Do you see why this very simple code gives me trouble?
var lastLocSuffix = _salespointAdapter.GetAll().Select(sp => new { LocSuffix = sp.LocSuffix }).OrderByDescending(sp => sp.LocSuffix).FirstOrDefault();
            Int16 newSuffix = 1;
            if (lastLocSuffix != null)                
                newSuffix = Convert.ToInt16(lastLocSuffix) + newSuffix; // Doesn't like this line

            salespoint.LocSuffix = newSuffix; 
I am trying to increment a number by 1. The number is supposed to be short. Why does it say something about cast if I declared the number to be short?

What am I missing in this code?

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform