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 .

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

1 Like

Hi,

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

System.Text.RegularExpressions.Regex.Replace(yourString,"(?=(^|\D)\d{2}($|\D))","20")

Regards,

1 Like

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