Want to check digit in a number

If I have two digit no. 21 …I want to check if it is two digit or 4 digit
If it is 2 digit then want to add 20 before that number…means 2021
And if it is 4 digit number then no further action .

if this number is your returned value you can use this:
if (digitVariable.ToString.Length) = 2
digitVariable = “20” + digitVariable

1 Like


Is your variable is String type? If so the following will work.



1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.