I have a class property 'FileSize_MB_InitialFile', declared as Int16. When I set it like this it works:
But when I set it like this (since I want MB, not bytes), it throws an error:
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:
I'm curious why it generates this error in the second instance.
Code:
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:
Code:
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:
Code:
this.FileSize_MB_InitialFile = Convert.ToInt16(fileInfo.Length / 1000);
I'm curious why it generates this error in the second instance.