MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/jtg3hx/getting_digits_using_switch_catch/gc68ha5/?context=3
r/badcode • u/HolySpecs • Nov 13 '20
52 comments sorted by
View all comments
3
I think this is better.
public static int evalDigit(string x) { int result = Convert.ToInt32(x); if(result > 9 || result < 0) { result = -1; } return result; }
Edit: Oh, it is in Java, I thought it was c#
2 u/MsRandom1 Nov 13 '20 Just replace Convert.ToInt32 with Integer.parseInt for it to work in java. 2 u/NinjoMCS Nov 13 '20 And an uppercase String
2
Just replace Convert.ToInt32 with Integer.parseInt for it to work in java.
2 u/NinjoMCS Nov 13 '20 And an uppercase String
And an uppercase String
3
u/hhellloo Nov 13 '20
I think this is better.
Edit: Oh, it is in Java, I thought it was c#