A
Anodes
I have a class property 'FileSize_MB_InitialFile', declared as Int16.
When I set it like this it works:
this.FileSize_MB_InitialFile = Convert.ToInt16(fileInfo.Length);
But when I set it like this (since I want MB, not bytes), it throws an
error:
this.FileSize_MB_InitialFile = Convert.ToInt16(fileInfo.Length) /
1000;
The error is "Cannot implicitly convert type 'int' to 'short'. An
explicit conversion exists (are you missing a cast?)"
Placing the division operation inside the parentheses works though:
this.FileSize_MB_InitialFile = Convert.ToInt16(fileInfo.Length /
1000);
I'm curious why it generates this error in the second instance.
When I set it like this it works:
this.FileSize_MB_InitialFile = Convert.ToInt16(fileInfo.Length);
But when I set it like this (since I want MB, not bytes), it throws an
error:
this.FileSize_MB_InitialFile = Convert.ToInt16(fileInfo.Length) /
1000;
The error is "Cannot implicitly convert type 'int' to 'short'. An
explicit conversion exists (are you missing a cast?)"
Placing the division operation inside the parentheses works though:
this.FileSize_MB_InitialFile = Convert.ToInt16(fileInfo.Length /
1000);
I'm curious why it generates this error in the second instance.