Hello every body, please could any one help me out there, i want to store value in a variable in a time format. for example if a user enter 3 on the console line the value should display like this 3:00:00. this is my code so far:
Console.Write("\n");
Console.Write(" {0,8}", "duration:\t");
length = Convert.ToString(Console.ReadLine(),@"d\.hh\:mm\:ss");
Console.Write("\n");
but not working out. I appreciate any help from from any one. thanks
Mohammed IbrahimPosted Aug 25, 2015, 4:42 AM
Console.WriteLine("Enter the data??");
string data;
//get the input data
data=Console.ReadLine();
//convert the data into integer
Int16 data1=Convert.ToInt16(data);
//convert the integer into the hours:min:secounds
//i have put given integer in the hours field and remining as zero
TimeSpan date=new TimeSpan(data1,00,00);
Console.WriteLine(date);
AmanPosted Aug 25, 2015, 4:26 AM