C
C#•11mo ago
realz

How do I typecast a string with a int

No description
14 Replies
Kouhai
Kouhai•11mo ago
int.TryParse(Console.ReadLine(), out int age) int.TryParse would return true if the string is parsable Otherwise it would return false And you get the result of the parsed string in the second argument
realz
realzOP•11mo ago
thank you
Kouhai
Kouhai•11mo ago
:peepoLovee:
realz
realzOP•11mo ago
No description
realz
realzOP•11mo ago
ruh roh it showed this
exokem
exokem•11mo ago
You have parentheses around the call
realz
realzOP•11mo ago
oh sh idk how that got there
realz
realzOP•11mo ago
is there anyway I can get the code not to display if not a number
No description
exokem
exokem•11mo ago
Store the return value of TryParse in a bool variable If it is false the response is not an int
realz
realzOP•11mo ago
can you show the line of code for that
realz
realzOP•11mo ago
i still couldn't figure it out idk what im doing wrong 😦
SG97
SG97•11mo ago
btw, you don't need to surround everything with { }
realz
realzOP•11mo ago
okay im used to html and css probably why ill come back tmrr

Did you find this page helpful?