So I have a placeholder question in the code that i am reviewing

{
            Console.Clear();
            Console.WriteLine("{0,24}", "Calories Burned");
            Console.WriteLine("\n{0,15}:{1,8:f1} hours", "Hours", hours);
            Console.WriteLine("{0,15}:{1,8:f1} minutes", "Minutes", minutes);
            Console.WriteLine("{0,6}:{1,8:f1} calories burned", "Calories Burned", CaloriesBurned);
            Console.ReadKey();
        }

I know the first half of the following code "{0,15}" , 0 is placeholder and "15" is the number of positions it will print that output to the right . But what is the part: "{1,8:f1)" 'f1' I understand its float one to the right.

"{0,15}:{1,8:f1} minutes"
{0,6}:{1,8:f1}

thanks again

Recommended Answers

All 4 Replies

Hi, this is called a floating-point number.
check here.

@Mitja wouldnt "{0,24} move the string value "Calories Burned" \

and (1,8:f1) shift the actual 'numerical value' correct? (in this case the value for hours}

That f1 has nothing to do with alignemnt. Its only meant for numerical values. It actually tell to compiler to round the number; number of decimal places.

For instance, if you have a number 12.3456 and you write "f2", it will round on 2 decimal places, so it will write out 12.34.
It even round up or down:
12.678 -> "f1" -> 12.7

One more thing to say, "f1" wil always write out a number with one decimal place.
So if you have a number 12, it will print out 12.0

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.