vb.net - why Tostring doesnot convert int to string -


consider code:

dim integer = 4 dim c integer = 3 console.writeline(a.tostring + c) console.readline() 

it should return 43 being converted string still return 7

because need convert both operands string, and/or use string concatenation operator &.

as stands, evaluating expression:

"4" + 3 

and vb decides convert first operand integer match second operand. vb perform string concatenation + if both operands strings. prefers arithmetic +.

some useful links:

as can see these links, setting of option strict plays role. have set off frankly setting on prudent.

personally i'd write this

a.tostring & c.tostring 

the bottom line if know want concatenate strings, clearer use dedicated string concatenation operator &.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -