RE: Specified cast is not valid

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



The GetInt16() function returns 'short' which is a C# datatype whereas Int16
is a .net framework's common data type. Although the sizes of both data types
may be the same they are considered as different data types since C# supports
strong type checking.
--
Thanks,
Sameeksha
MCAD.Net


"simon" wrote:

> I declare variable as int16:
>
> int16 hourS;
>
> then I open dataReader and set the variable:
>
> hourS=rdr.getInt16(1);
>
> but I get an error when I start the page:
>
> "Specified cast is not valid."
>
> I don't understand why?
> Both sides are defined as int16, also the value which reader returns is
> small, like 5 for example.
>
> I know, I can use convert function:
>
> hourS=convert.Toint16(rdr.getInt16(1));
>
> it works, but doesn't make sense.
>
> Regards,S
>
>
>
.



Relevant Pages

  • Re: Function * not defined for variables of class int16.
    ... Mathworks does not supply a method that allows you to matrix multiply int16 (or int8) variables. ... If you want to multiply them you'll need to cast them to different data types, ... Integer datatypes have been around for a while now, but we are still quite limited in what we can do with them. ...
    (comp.soft-sys.matlab)
  • Re: Specified cast is not valid
    ... > Although the sizes of both data types ... > may be the same they are considered as different data types since ... Int16 and are considered the *same* datatype. ...
    (microsoft.public.dotnet.languages.csharp)