0

I'm confused. What does the "Convert.ToInt32" statement do? I keep seeing it throughtout the course lessons, but don't remember the app talking about it.

18th Aug 2016, 1:21 PM
Daniel Hildreth
Daniel Hildreth - avatar
5 Antworten
+ 3
It would cast any primitive type ( it takes int as well as strings or chars ) and convert them to a 32-bit signed integer. You can use parsing as well: int.Parse( string ) if you know the string is going to be an int, or int.TryParse(string, out int x) if you are not sure about it, which will return a bool, and if it is true, you can run it in an if statement and you will have the expected number in x.
18th Aug 2016, 4:38 PM
Elie Saad
Elie Saad - avatar
0
@Elie Saad What is a 32 bit signed integer, and what are they used for?
18th Aug 2016, 6:04 PM
Daniel Hildreth
Daniel Hildreth - avatar
0
In the .NET framework, signed integers are used. The size of a signed integer goes up to 2^31 - 1 and can go to the negative of that value. The difference between the signed and unsigned is that signed take the 32th bit and uses it for either positive value (0) and negative for (1).
18th Aug 2016, 6:37 PM
Elie Saad
Elie Saad - avatar
0
do the signed help manage memory resources?
18th Aug 2016, 8:04 PM
Daniel Hildreth
Daniel Hildreth - avatar
0
It convert other datatype values to integer . you can use int.parse also
20th Sep 2016, 5:15 PM
Laze Hang
Laze Hang - avatar