Click here to Skip to main content
15,914,162 members
Home / Discussions / C#
   

C#

 
GeneralRe: Open-files-problem Pin
Dave Kreskowiak11-Aug-04 10:44
mveDave Kreskowiak11-Aug-04 10:44 
GeneralRe: Open-files-problem Pin
Member 80940911-Aug-04 10:52
Member 80940911-Aug-04 10:52 
GeneralPlease try to help me.. Pin
sreejith ss nair12-Aug-04 2:27
sreejith ss nair12-Aug-04 2:27 
GeneralRe: Please try to help me.. Pin
Dave Kreskowiak12-Aug-04 12:57
mveDave Kreskowiak12-Aug-04 12:57 
GeneralWeird Build Problem Pin
Guinness4Strength11-Aug-04 5:47
Guinness4Strength11-Aug-04 5:47 
GeneralString formatting problems Pin
moredip11-Aug-04 5:27
moredip11-Aug-04 5:27 
GeneralRe: String formatting problems Pin
sreejith ss nair11-Aug-04 7:33
sreejith ss nair11-Aug-04 7:33 
GeneralRe: String formatting problems Pin
moredip11-Aug-04 7:46
moredip11-Aug-04 7:46 
Umm, I'm not sure how much more specific I can be, but I'll try Smile | :)

Ok, I have a variable of type double, let's call it dNumber.

I want to create a string that represents that number. Let's call the string strFormatted.

The string must be formatted as follows:

the 1st character is a space
the next 7 characters represent the number
the string must always be 8 characters in length

here's some examples of correctly formatted strings.

12345678 <- characters in string
--------
 1.34567
 1234.67
 0.23456



I figured the following function would do the trick:

string FormatToFortran( double dNumber )
{
return String.Format( " {0,7:g}", dNumber );
}

but unfortunately it doesn't. Format() seems to be ignoring the alignment section of the format string (the 7), and strings returned by FormatToFortran() are similar to the following:

 130.312393712128
 136.399493519436
 121.295216530426

obviously, these aren't 8 characters in length.

So, I'm wondering what is wrong with my format string.

Hope that clarifies things. If not, feel free to ask away!

Cheers,

Pete
GeneralRe: String formatting problems Pin
sreejith ss nair11-Aug-04 8:01
sreejith ss nair11-Aug-04 8:01 
GeneralRe: String formatting problems Pin
moredip11-Aug-04 8:05
moredip11-Aug-04 8:05 
GeneralRe: String formatting problems Pin
moredip11-Aug-04 9:29
moredip11-Aug-04 9:29 
GeneralSafe version of unsafe code Pin
cheesepirate11-Aug-04 5:11
cheesepirate11-Aug-04 5:11 
GeneralRe: Safe version of unsafe code Pin
Mardawi11-Aug-04 10:04
Mardawi11-Aug-04 10:04 
GeneralRe: Safe version of unsafe code Pin
Anonymous11-Aug-04 10:56
Anonymous11-Aug-04 10:56 
QuestionRestricting Form-Moving to horizontal? Pin
jkersch11-Aug-04 4:17
jkersch11-Aug-04 4:17 
AnswerRe: Restricting Form-Moving to horizontal? Pin
Not Active11-Aug-04 4:58
mentorNot Active11-Aug-04 4:58 
GeneralRe: Restricting Form-Moving to horizontal? Pin
jkersch11-Aug-04 5:14
jkersch11-Aug-04 5:14 
GeneralXmlValidatingReader Pin
Not Active11-Aug-04 3:59
mentorNot Active11-Aug-04 3:59 
GeneralRe: XmlValidatingReader Pin
VenkatFor.NET11-Aug-04 7:28
VenkatFor.NET11-Aug-04 7:28 
GeneralRe: XmlValidatingReader Pin
Not Active12-Aug-04 3:57
mentorNot Active12-Aug-04 3:57 
QuestionDo you see the same results??? Pin
LongRange.Shooter11-Aug-04 3:13
LongRange.Shooter11-Aug-04 3:13 
AnswerRe: Do you see the same results??? Pin
Nick Parker11-Aug-04 4:16
protectorNick Parker11-Aug-04 4:16 
GeneralRe: Do you see the same results??? Pin
LongRange.Shooter11-Aug-04 5:43
LongRange.Shooter11-Aug-04 5:43 
GeneralDirectX Pin
rafQ11-Aug-04 2:29
rafQ11-Aug-04 2:29 
GeneralUrgent Regarding Directoryentry.Invoke(Setpassword,&quot;&quot;) method Pin
shambho11-Aug-04 2:24
shambho11-Aug-04 2:24 

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.