String.Format?
string s = String.Format("{0:F2}", num);
Rashakil Fol
Super Senior Demiposter
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
You can even do things like
s += String.Format("{0:F2} ", num1);
s += String.Format("{0:F3}", num2);
This would give you a string of two numbers separated by a space.
One with 2 digits after the decimal point(which is the default, you don't have to mention it if you like) and one with 3 digits after the decimal point.
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
s += String.Format("{0:F2} ", num1);
s += String.Format("{0:F3}", num2);
Ruh roh, you forgot to use code tags!
But seriously in that contrived case you'd just write string s = String.Format("{0:F2} {1:F3}", num1, num2);
Rashakil Fol
Super Senior Demiposter
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
Rashakil : You are absolutly right! But...
This was a Quick Reply to Thread!
And I rarely use code tags for one or two lines of code, if I hurted your feelings : I'm sorry.
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
With everything in .net being a class/object, what I think he means is if you were in c++ or any other lanugage, a data type such as int/string/char etc has no methods, its a datatype, whereas in .net, of course it has methods.
LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
you would have great respect for many of the features in c#, but also great dissapointment in the speed of execution (there's no pointers!).
Today it is the speed of development that counts.
If you want to use pointers in C# go ahead!
Why do you think there is a C in C#?
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661