C
C#•8mo ago
realz

How do I typecast a string with a int

No description
14 Replies
Kouhai
Kouhai•8mo 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•8mo ago
thank you
Kouhai
Kouhai•8mo ago
:peepoLovee:
realz
realzOP•8mo ago
No description
realz
realzOP•8mo ago
ruh roh it showed this
exokem
exokem•8mo ago
You have parentheses around the call
realz
realzOP•8mo ago
oh sh idk how that got there
realz
realzOP•8mo ago
is there anyway I can get the code not to display if not a number
No description
exokem
exokem•8mo ago
Store the return value of TryParse in a bool variable If it is false the response is not an int
realz
realzOP•8mo ago
can you show the line of code for that
realz
realzOP•8mo ago
i still couldn't figure it out idk what im doing wrong 😦
SG97
SG97•8mo ago
btw, you don't need to surround everything with { }
realz
realzOP•8mo ago
okay im used to html and css probably why ill come back tmrr
Want results from more Discord servers?
Add your server