C Board  

Go Back   C Board > General Programming Boards > C# Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 07-27-2009, 12:40 PM   #1
Registered User
 
Join Date: Jul 2009
Posts: 8
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?
-Od|n- is offline   Reply With Quote
Old 07-27-2009, 02:44 PM   #2
Confused
 
Magos's Avatar
 
Join Date: Sep 2001
Location: Sweden
Posts: 3,125
Code:
Console.WriteLine("The circumference is : " + circumfere);
__________________
MagosX.com

Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
Magos is online now   Reply With Quote
Old 07-27-2009, 10:00 PM   #3
Registered User
 
Join Date: Jul 2009
Posts: 8
Quote:
Originally Posted by Magos View Post
Code:
Console.WriteLine("The circumference is : " + circumfere);
yea ok man thanx a bunch
-Od|n- is offline   Reply With Quote
Old 07-27-2009, 10:51 PM   #4
int x = *((int *) NULL);
 
Cactus_Hugger's Avatar
 
Join Date: Jul 2003
Location: Banks of the River Styx
Posts: 902
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);
__________________
long time; /* know C? */
Unprecedented performance: Nothing ever ran this slow before.
Any sufficiently advanced bug is indistinguishable from a feature.
Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
The best way to accelerate an IBM is at 9.8 m/s/s.
recursion (re - cur' - zhun) n. 1. (see recursion)
Cactus_Hugger is offline   Reply With Quote
Old 07-27-2009, 11:37 PM   #5
Guest
 
Sebastiani's Avatar
 
Join Date: Aug 2001
Posts: 5,034
>> 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.
Sebastiani is offline   Reply With Quote
Old 07-28-2009, 05:05 AM   #6
int x = *((int *) NULL);
 
Cactus_Hugger's Avatar
 
Join Date: Jul 2003
Location: Banks of the River Styx
Posts: 902
Quote:
Originally Posted by Sebastiani View Post
>> 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.
__________________
long time; /* know C? */
Unprecedented performance: Nothing ever ran this slow before.
Any sufficiently advanced bug is indistinguishable from a feature.
Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
The best way to accelerate an IBM is at 9.8 m/s/s.
recursion (re - cur' - zhun) n. 1. (see recursion)
Cactus_Hugger is offline   Reply With Quote
Old 07-28-2009, 10:49 AM   #7
Registered User
 
Join Date: Jul 2009
Posts: 8
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)...
-Od|n- is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
validation problem in a loop (newbie question) Aisthesis C++ Programming 11 05-10-2009 10:47 PM
Newbie problem with scanf function... Mithal C Programming 1 11-13-2005 10:28 PM
Newbie ... looping problem StupidIntel C++ Programming 12 05-13-2004 06:45 PM
Problem with code (newbie question) Unregistered C++ Programming 5 07-31-2002 01:39 AM
newbie coding problem rippascal C++ Programming 10 01-08-2002 11:45 PM


All times are GMT -6. The time now is 06:35 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22