Android Question casting to and from numeric EditText.Text

a n g l o

Active Member
Licensed User
Longtime User
is it totally safe to handle without casting :
B4X:
Dim i as int=EditText1.Text+EditText2.Text

or is it safer to use :
B4X:
Dim i as int=EditText1.Text.AS(int)+EditText2.Text.AS(int)

both EditTexts are numeric.

same Q for the opposite direction (from int to EditText.Text with/without casting to string)

Thank you
 

teddybear

Well-Known Member
Licensed User
Both of them are safe, they use same method Double.parseDouble to do casting. just one does an explicit casting.
From int to EditTextEditText.Text with/without casting to string. both of them use NumberToString method, no difference
 
Upvote 0
Top