2

I have a simple method that creates numbers 13:35 - 14:31. Right now all it does is print out the numbers using a

Console.WriteLine

I was wondering if there's a way to store this into an array say

string[] numbers = new string[57];

Here is what I have so far:

 int min1 = 1;
        int min2 = 3;
        int sec1 = 3;
        int sec2 = 5;
        string a = "{0}{1}:{2}{3}";
        string[] numbers = new string[57];
        for (int i = 0; i < 57; i++)
        {
            Console.WriteLine(a,min1, min2, sec1, sec2);

            sec2 = sec2 + 1;
            if (sec2 == 10)
            {
                sec2 = 0;
                sec1 = sec1 + 1;
            }
            if (sec1 == 6 && sec2 == 0)
            {
                sec1 = 0;
                sec2 = 0;
                min2 = min2 + 1;
            }
            if (min2 == 0)
            {
                min2 = 0;
                min1 = min1 + 1;
            }

        }

Thank you in advance!!

3 Answers 3

7

You can use string.Format for that:

numbers[i] = string.Format(a, min1, min2, sec1, sec2);
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you dasbinkenlight you're the best!
2

Are you looking for:

numbers[i] = string.Format(a,min1, min2, sec1, sec2);

Comments

2
        numbers[i] = String.Format(a,min1, min2, sec1, sec2);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.