# Newbie problem

• 07-27-2009
-Od|n-
Newbie problem
decimal PI = 3.14159M;
int radius = 4;
decimal circumfere;
int diameter;

diameter = 2 * radius;
circumfere = PI * diameter;

Console.WriteLine("The circumference is : ", circumfere);

Its a program to calculate the circumference of a circle on c# Console application, it only displays "The circumference is : " and nothing else..

can one of you help me?
• 07-27-2009
Magos
Code:

`Console.WriteLine("The circumference is : " + circumfere);`
• 07-27-2009
-Od|n-
Quote:

Originally Posted by Magos
Code:

`Console.WriteLine("The circumference is : " + circumfere);`

yea ok man thanx a bunch
• 07-27-2009
Cactus_Hugger
For more complex strings, you'll find formatting easier. (Concatentation is fine in this case) Following your initial attempt:
Code:

`Console.WriteLine("The circumference is : {0}", circumference);`
• 07-28-2009
Sebastiani
>> For more complex strings, you'll find formatting easier. (Concatentation is fine in this case) Following your initial attempt:

True, but it's error prone and a pain to make changes. I would use the concatenation approach in every case, personally.
• 07-28-2009
Cactus_Hugger
Quote:

Originally Posted by Sebastiani
>> For more complex strings, you'll find formatting easier. (Concatentation is fine in this case) Following your initial attempt:

True, but it's error prone and a pain to make changes. I would use the concatenation approach in every case, personally.

String.Format() has an additional advantage that it also makes internationalization easier. There are some cases where concatention != format strings, such as:
Code:

`String.Format("{0} cat", color == Color.Black ? "black" : "blue")`
Had you used concatentation, i18n would have been much harder. With format strings, we need only change the string literals in this (and most) cases. In french for example:
Code:

`String.Format("char {0}", color == Color.Black ? "noir" ? "bleu")`
Additionally, I find that for longer strings, format strings generally increase readability.
• 07-28-2009
-Od|n-
k i understand the difference betwen using commas and the concatenation sign now thanx a bunch although I havn't gotten to string formatting yet ( last post)...