Click here to Skip to main content
15,900,461 members
Home / Discussions / C#
   

C#

 
GeneralRe: Custom textbox with dropdownlist behavior Pin
hansdredd23-Feb-06 20:52
hansdredd23-Feb-06 20:52 
QuestionWhy doesn't the compiler flag classes with public unlong-s as erroneous although the assembly is CLS compliant? Pin
Vikram A Punathambekar21-Feb-06 3:53
Vikram A Punathambekar21-Feb-06 3:53 
AnswerRe: Why doesn't the compiler flag classes with public unlong-s as erroneous although the assembly is CLS compliant? Pin
Judah Gabriel Himango21-Feb-06 6:30
sponsorJudah Gabriel Himango21-Feb-06 6:30 
GeneralRe: Why doesn't the compiler flag classes with public unlong-s as erroneous although the assembly is CLS compliant? Pin
Vikram A Punathambekar21-Feb-06 16:31
Vikram A Punathambekar21-Feb-06 16:31 
GeneralRe: Why doesn't the compiler flag classes with public unlong-s as erroneous although the assembly is CLS compliant? Pin
Judah Gabriel Himango21-Feb-06 17:12
sponsorJudah Gabriel Himango21-Feb-06 17:12 
GeneralRe: Why doesn't the compiler flag classes with public unlong-s as erroneous although the assembly is CLS compliant? Pin
Vikram A Punathambekar21-Feb-06 21:15
Vikram A Punathambekar21-Feb-06 21:15 
Questionlimiting the number of decimal places produced converting a double to a string. Pin
Dan Neely21-Feb-06 3:50
Dan Neely21-Feb-06 3:50 
AnswerRe: limiting the number of decimal places produced converting a double to a string. Pin
Vikram A Punathambekar21-Feb-06 4:07
Vikram A Punathambekar21-Feb-06 4:07 
Dan,

If you want a leading 0 to appear ONLY when the double's integer part is 0, put a 0 between the last hash in the integer part and the decimal point.
double d;
string s;
d = 0.001;
s = d.ToString();
Console.WriteLine(s);
s= d.ToString("########0.####");
Console.WriteLine(s);

produces the output
0.001
0.001


For the special case of 0.0, you will have to add an extra zero between the decimal point and the first hash of the fractional part. Your format string now looks like
"########0.0####"


Now, the output of
using System;

class Foo
{
	public static int Main(string[] args)
	{
		double d;
		string s;
		d = 0.120;
		s= d.ToString("########0.0####");
		Console.WriteLine(s);
		d = 0.0;
		s= d.ToString("########0.0####");
		Console.WriteLine(s);
		return 0;
	}
}

will be
0.12
0.0


I hope that answers your question, and thanks for making me learn something today. Wink | ;) However, please check the code yourself because it's 8:45 PM here and I did this in a hurry.

PS: Let me know if I was right. Smile | :)

Cheers,
Vikram.
"When I read in books about a "base class", I figured this was the class that was at the bottom of the inheritence tree. It's the "base", right? Like the base of a pyramid." - Marc Clifton.
GeneralRe: limiting the number of decimal places produced converting a double to a string. Pin
Dan Neely21-Feb-06 6:54
Dan Neely21-Feb-06 6:54 
GeneralRe: limiting the number of decimal places produced converting a double to a string. Pin
Vikram A Punathambekar21-Feb-06 16:28
Vikram A Punathambekar21-Feb-06 16:28 
QuestionOh... Joy! App failing and I don't know why Pin
Colin Angus Mackay21-Feb-06 3:43
Colin Angus Mackay21-Feb-06 3:43 
QuestionComboBox Enter Key Detection Issue Pin
Darryl Borden21-Feb-06 3:17
Darryl Borden21-Feb-06 3:17 
Questionpassing parameters Pin
leelaraj21-Feb-06 2:37
leelaraj21-Feb-06 2:37 
AnswerRe: passing parameters Pin
CWIZO21-Feb-06 3:34
CWIZO21-Feb-06 3:34 
AnswerRe: passing parameters Pin
Le centriste21-Feb-06 5:03
Le centriste21-Feb-06 5:03 
GeneralRe: passing parameters Pin
leelaraj21-Feb-06 16:55
leelaraj21-Feb-06 16:55 
GeneralRe: passing parameters Pin
Le centriste22-Feb-06 1:24
Le centriste22-Feb-06 1:24 
Questionscrolling test at the top like banner Pin
leelaraj21-Feb-06 2:25
leelaraj21-Feb-06 2:25 
AnswerRe: scrolling test at the top like banner Pin
Andy Moore21-Feb-06 3:09
Andy Moore21-Feb-06 3:09 
QuestionViwing crystal report on web Pin
Amestris21-Feb-06 2:15
Amestris21-Feb-06 2:15 
QuestionWeb service Pin
magnifique21-Feb-06 1:12
magnifique21-Feb-06 1:12 
AnswerRe: Web service Pin
J4amieC21-Feb-06 2:15
J4amieC21-Feb-06 2:15 
GeneralRe: Web service Pin
magnifique21-Feb-06 22:59
magnifique21-Feb-06 22:59 
QuestionReading different Language Words Pin
cshivaprasad21-Feb-06 1:10
cshivaprasad21-Feb-06 1:10 
AnswerRe: Reading different Language Words Pin
Ingo21-Feb-06 1:39
Ingo21-Feb-06 1:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.