-4
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FloatConversion
{ 
    class MainApp
    {
        static void Main(string[] args)
        {
            float a = 69.6875f;
            Console.WriteLine("a : {0}", a);

            double b = (double)a;
            Console.WriteLine("b : {0}", b);

            Console.WriteLine("69.6875 == b : {0}", 69.6875 == b);

            float x = 0.1f;
            Console.WriteLine("x : {0}", x);

            double y = (double)x;
            Console.WriteLine("y : {0}", y);

            Console.WriteLine("0.1 == y : {0}", 0.1 == y);



            Console.ReadLine();
        }
    }
}

I just started learning C#. As a Newbie, I was wondering that what a : {0} means in Console.WriteLine() method.

similarly, what does 69.6875 == b : {0} mean? how can it be displayed as a boolean?

Thank u in advance.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • 1
    Check [String.Format Method](https://msdn.microsoft.com/en-us/library/system.string.format(v=vs.110).aspx) which is exactly what `Console.WriteLine` is doing – Fabio May 14 '18 at 04:47

1 Answers1

2

{} is used to format your string, value inside {} shows index of argument which we are passing in Console.WriteLine, followed by string.

In your case, in first Console.WriteLine(), {0} will be replaced with value of argument a(which you passed after "a:{0}").

Here you can get detailed description of String format: MSDN string format

Prasad Telkikar
  • 15,207
  • 5
  • 21
  • 44