I'm trying to output a time. I have an int representing the hours and the minutes. Both need to be two digits, and they need to be output as string variables.
How do I output the numbers with two places?
For example, assume that
int hour = 8, int minute = 5
I need to make string timeOutput = 8:05
I thought it was
timeOutput = ("{0:D2}:{1:D2} ", hour, minute);
But that doesn't wo...
User Profile
Collapse
-
How to convert an int to a string with a fixed point?
-
What is wrong with my foreach loop?
EDIT: I figured out my problem. Thanks.
There was no problem with my loop. The error was elsewhere in my code.
............... ............... ............... .Last edited by Steven Sargent; Feb 24 '11, 04:13 AM. Reason: Solved problem on my own before any replies were posted -
That worked great for outputting the characters or putting them in an array. But what if I only want to work with a single character? -
Can I use the split method to separate every character in a string?
I want to know if there is a way to use the split function to separate every single character. For example, if I input "Hello", the program will output
H
e
l
l
o
Every tutorial I've found describes how to split the string on one or more specific characters. -
Actually, that's exactly what I had considered first... I don't think I explained myself well.
At any rate, I was hoping there was a quicker way that I wasn't seeing.
Thanks.Leave a comment:
-
How do I convert a number in to its written form?
How can I convert a number into its written form?
For example, I input 15, and the program will output "fifteen".
I'm doing this in a console application. It would be better if, instead of giving me the full answer, you could set me on the right path.
All I can think of now is a very long switch structure for every character in the number.
No activity results to display
Show More
Leave a comment: