Suppose we have to input data for date of birth. Let we say 11/23/1998 (mm/dd/yyyy). In practice we have to input 11 then we have to input / and so on. I wish to know whether it is possible when we input 11 display will be 11/ that means / will automatically come with 11.
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.Write("DOB mm/dd/yyyy ");
string s = Console.ReadLine();
Console.ReadKey();
}
}
}
Loading

VulpesRank #55 · 29.2K reputationPosted Feb 21, 2012, 1:15 PM EST
In fact, if you're going to do that you might as well validate the date as the user enters it at the same time.
The following, if I've written it correctly, should beep and refuse to accept invalid input as well as automatically inserting the forward slashes:
Posted Feb 21, 2012, 1:27 PM EST
I will go through step by step and get back if I have any problem.
Prime bRank #2,035 · 712 reputationPosted Feb 21, 2012, 1:28 PM EST