Click here to Skip to main content
15,896,153 members
Home / Discussions / C#
   

C#

 
QuestionWebClient.DownloadFileAsync Pin
#realJSOP17-Jul-08 12:06
professional#realJSOP17-Jul-08 12:06 
AnswerRe: WebClient.DownloadFileAsync Pin
N a v a n e e t h17-Jul-08 17:49
N a v a n e e t h17-Jul-08 17:49 
GeneralRe: WebClient.DownloadFileAsync Pin
#realJSOP17-Jul-08 23:16
professional#realJSOP17-Jul-08 23:16 
QuestionC# WinForms: Read/Display Multipage Tiff image. Pin
ImNAM17-Jul-08 10:18
ImNAM17-Jul-08 10:18 
AnswerRe: C# WinForms: Read/Display Multipage Tiff image. [modified] Pin
astanton197818-Jul-08 1:16
astanton197818-Jul-08 1:16 
GeneralRe: C# WinForms: Read/Display Multipage Tiff image. Pin
ImNAM18-Jul-08 3:49
ImNAM18-Jul-08 3:49 
GeneralRe: C# WinForms: Read/Display Multipage Tiff image. Pin
astanton197821-Jul-08 1:35
astanton197821-Jul-08 1:35 
QuestionHow to format a number with an implied decimal Pin
Steve Messer17-Jul-08 8:46
Steve Messer17-Jul-08 8:46 
I am senting data in a flat file to a client who is parsing the data using Cobol and he is
asking me to format money with an implied decimal point padded to 6 charaters in length.

For example given $15 dollars he wants me to send either

001500 or 1500 I am not sure which yet but the problem is the same either way.

I have a generic tool that allows me to pick a field to send and also to provide the
formating to apply.

Here is the method I call each time a number needs to be formatted:


static public string ProcessNumber(string amount, string format)
{
     decimal temp;
            
     bool results = decimal.TryParse(amount, out temp);

     if(results)
     {
         string localFormat = string.IsNullOrEmpty(format) ? "0.00" : format;
         string convertedValue = temp.ToString(localFormat);
         return convertedValue;
     }

     return amount;
}


Normally, for money I would use the "0.00" or "000.00" format specifier when
yields 15.00 or 015.00 respectively.

I don't want to have to treat this request as a one off and write special code if I don't have to.

I can't assume in any given case that the decimal will or won't be implied.

Is there a way to apply a format to yield a textual representation of a number with an implied decimal place?
AnswerRe: How to format a number with an implied decimal Pin
PIEBALDconsult17-Jul-08 9:05
mvePIEBALDconsult17-Jul-08 9:05 
GeneralRe: How to format a number with an implied decimal Pin
Steve Messer17-Jul-08 9:11
Steve Messer17-Jul-08 9:11 
GeneralRe: How to format a number with an implied decimal Pin
Pete O'Hanlon17-Jul-08 10:27
mvePete O'Hanlon17-Jul-08 10:27 
GeneralRe: How to format a number with an implied decimal Pin
Steve Messer17-Jul-08 10:32
Steve Messer17-Jul-08 10:32 
GeneralRe: How to format a number with an implied decimal Pin
Pete O'Hanlon17-Jul-08 10:39
mvePete O'Hanlon17-Jul-08 10:39 
GeneralRe: How to format a number with an implied decimal Pin
PIEBALDconsult17-Jul-08 14:49
mvePIEBALDconsult17-Jul-08 14:49 
GeneralRe: How to format a number with an implied decimal Pin
Steve Messer17-Jul-08 18:09
Steve Messer17-Jul-08 18:09 
GeneralRe: How to format a number with an implied decimal Pin
PIEBALDconsult18-Jul-08 13:48
mvePIEBALDconsult18-Jul-08 13:48 
GeneralRe: How to format a number with an implied decimal Pin
Steve Messer18-Jul-08 17:07
Steve Messer18-Jul-08 17:07 
GeneralRe: How to format a number with an implied decimal Pin
PIEBALDconsult19-Jul-08 3:34
mvePIEBALDconsult19-Jul-08 3:34 
GeneralRe: How to format a number with an implied decimal Pin
Steve Messer19-Jul-08 13:49
Steve Messer19-Jul-08 13:49 
AnswerRe: How to format a number with an implied decimal Pin
SilimSayo17-Jul-08 9:26
SilimSayo17-Jul-08 9:26 
GeneralRe: How to format a number with an implied decimal Pin
Steve Messer17-Jul-08 9:43
Steve Messer17-Jul-08 9:43 
GeneralRe: How to format a number with an implied decimal Pin
darkelv17-Jul-08 17:08
darkelv17-Jul-08 17:08 
GeneralRe: How to format a number with an implied decimal Pin
Steve Messer17-Jul-08 18:12
Steve Messer17-Jul-08 18:12 
GeneralRe: How to format a number with an implied decimal Pin
darkelv17-Jul-08 19:23
darkelv17-Jul-08 19:23 
GeneralRe: How to format a number with an implied decimal Pin
Steve Messer18-Jul-08 3:35
Steve Messer18-Jul-08 3:35 

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.