C
C#•10mo ago
realz

How do I typecast a string with a int

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