Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Constants (such as 1 or 0) -> Int16 ?
Message
De
25/04/2014 14:28:03
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01599064
Message ID:
01599073
Vues:
50
This message has been marked as a message which has helped to the initial question of the thread.
J'aime (1)
>>>Hi everybody,
>>>
>>>Quite often when I need to compare, say, two values where one is a constant, I need to put (Int16) in front of that constant to avoid a compile error. I am wondering is there a way to somehow automatically make 0 to be Int16 without explicitly boxing it?
>>>
>>>Thanks in advance.
>>
>>I think you mean 'casting' rather than 'boxing' ?
>>
>>How are you declaring the constant ?
>
>Here is one of the samples (I introduce the constant inline same way as in the VFP code I am translating):
>
>
>DateTime admission_end = this.dtScan.Date.AddDays(Math.Max(admissions, (Int16)1)).AddSeconds(-1);
Generally you could use a literal suffix to override the default data type: http://www.blackwasp.co.uk/CSharpNumericLiterals.aspx

But... while literal suffixes work for most numeric types, short isn't one of them.
Very fitting: http://xkcd.com/386/
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform