Perhaps you can try this, it works with doubles but you can convert decimal to double.
static void Main(string args)
double DecNum = 13.573451;
string TheTime = MakeTimeString(DecNum);
DecNum = 1.25;
TheTime = MakeTimeString(DecNum);
Console.ReadKey(); // hold console until a key is pressed
static string MakeTimeString(double num)
double hours = Math.Floor(num); //take integral part
double minutes = (num - hours) * 60.0; //multiply fractional part with 60
//double seconds = (minutes - Math.Floor(minutes)) * 60.0; //add if you want seconds
int H = (int)Math.Floor(hours);
int M = (int)Math.Floor(minutes);
//int S = (int)Math.Floor(seconds); //add if you want seconds
return H.ToString() + ":" + M.ToString(); //+":" + S.ToString(); //add if you want seconds
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...