casting - C# - How to get a long type variable defined by user in a TextBox and use it in a mathematical operation -


i need text field of program treated long type variable , processed in mathematical operation. value of variable needs specified every time user , want program treat value not integer long indeed.

i have treated other fields integer , work fine kind of code:

hourfield.intvalue 

now notice .intvalue says program take content of hourfield whatever in , treat integer. unfortunately there no equivalent long type in fact if try write .longvalue, c# doesn't recognise function....there other similar functions .floatvalue or .doublevalue etc. there no such thing .longvalue. tried use kind of syntax:

convert.toint64(filesizebytesfield); 

or , in theory compiler doesn't give me error compilation etc. if try make calculation pressing button program crashes , visual studio tells me type of casting invalid. please please pease me this. it's last thing need finish program!!!

p.s. posting screenshots of got , of source code. thanks

program's source code

debugging error in visual studio after program crash

i guess filesizebytesfield trying take value instance of nstextfield or subclass of nscontrol. in case, can take value of control using properties intvalue or stringvalue. so, convert value long type try this:

convert.toint64(filesizebytesfield.stringvalue) 

or, using more common approach suggested hooman bahreini:

long filesizebytes; if (long.tryparse(filesizebytesfield.stringvalue, out filesizebytes)) {   // use filesizebytes }  

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -