>>>>>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);
>>
>>So not a constant - a hard coded value thus it will be Int32 and require casting (unless admissions is also Int32)
>>Do what Craig suggests and use an actual constant.
>
>It is funny, but I just found out that in one table this column was defined as smallint while in another as numeric(6,2) (which is most likely a mistake).
Sounds like your mixing up SQL and .NET data types ?
>So, right now for the admissions variable I put the following code
>
>
>Int16 admissions = Convert.ToInt16(drItem.Field<Decimal>("admissions"));
>
>and didn't yet have a chance to test it.
>
>I put constants declaration at the very top of the class for now (as they may be used in different methods).