Ask coding questions

← Back to all posts
C# 4 digits integer starting with 0
firefish (742)

In this repl, one of the input numbers starts with 0. They are converted to strings later on, but the length check on each of the numbers fails, because the 0 is cut off. Is there a way to set the length of digits to be the same always, or should I change the input type to a string?
(The problem is in the sequence.cs file; the input is in the main.cs file)

UPDATE:
I have changed the input type to strings, as it shortens the amount of code needed.

Answered by mwilki7 (1112) [earned 5 cycles]
View Answer
Commentshotnewtop
firefish (742)

@mwilki7 I have read that post, and the maths trick, although it works, just seems inconvenient. I think I'm going to just convert input type to strings, as it shortens the amount of code needed.