61767447

CSharp · Console

/Program.cs

using System;
					
public class Program
{
	public static void Main()
	{
		Console.WriteLine(ValidatePin("1234"));
		Console.WriteLine(ValidatePin("12345"));
		Console.WriteLine(ValidatePin("a234"));
	}
	
    public static bool ValidatePin(string pin)
    {

       //below condition will return true if length is 4 or 6, otherwise false
       var condition = (pin.Length == 4 || pin.Length == 6) && int.TryParse(pin, out int pinn);
       return condition;
    }
}
;