Can someone explain difference in this 2 codes.
Console.WriteLine("Our total"+ total);
and
Console.WriteLine("Our total {0}", total);
Which of code is more or less correctly than other?
In this line
Console.WriteLine("Our total"+ total);
will always contact after left side of + sign is finish.
In this line
Console.WriteLine("Our total {0}", total);
will print where it's position is putted.
Like
Console.WriteLine("{0} is our total ", total);
This'll print first in the string.
if total is 10
Output :
10 is our total.
Both is correct but with different way of printing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With