Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
String.Format
Message
De
18/02/2013 13:35:25
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01566272
Message ID:
01566292
Vues:
39
> 0m,
>> 1m
>> };
>>
>> foreach (decimal x in values)
>> Console.WriteLine("{0,20:$#,##0.00}", x);
>>
>>
>> StringBuilder sb = new StringBuilder();
>> sb.AppendFormat("{0,20:$#,##0.00}", 11211105.99m);
>> Console.WriteLine(sb.ToString());
>> Console.ReadLine();
>> }
>>
>>
>>
>>
>
>Doesn't matter what I try I am getting one of the two errors: "Input string was not in the correct format" or "Format specification is invalid".
>
>Do you see what I am doing wrong or how can I figure this out?
>
>
>            displayString.AppendFormat("{0}  {1}   {2}{3}   {4D16}{5D16}  {6}  {7}{3}{3}", 
>                                            Convert.ToDecimal(row["extension"]), Convert.ToDateTime(row["date_time"]), message, Environment.NewLine,
>                                            row["sale_no"].ToString(), row["trans_no"].ToString(), 
>                                            row["operator"].ToString(), row["salespoint"].ToString());
>                                    }
>                                    displayString.AppendLine("------------");
>                                    displayString.AppendFormat("{0C}{2}{1C}  Against This Sale{2}", balance, saleTotal, Environment.NewLine);
>                                    messageText = displayString.ToString();
>
>
>If I remove D16 from above it seems to pass that line OK.

(1) Do not convert sale_no and trans_no ToString()
(2)
Console.WriteLine("{0:0000000000000000}", 123);
>The VFP code is
>
>
> scan
>               lvRetVal=lvRetVal+;
>                  transform(extension, '$,$$$,$$9.99')+'  '+;
>                  transform(date_time)+'  '+;
>                  padr(iif(department='**TRANS** ', message, department+'/'+category+'/'+item),32)+' '+;
>                  chr(13)+chr(10)+;
>                  '  '+transform(sale_no, '9999999999999999')+transform(trans_no, '9999999999999999')+' '+;
>                  operator+' '+;
>                  salespoint+chr(13)+chr(10)+chr(13)+chr(10)
>            endscan
>            lvRetVal=lvRetVal+;
>               '------------'+chr(13)+chr(10)+;
>               transform(lnInvBal, '$,$$$,$$9.99')+chr(13)+chr(10)+;
>               transform(lnThisSale, '$,$$$,$$9.99')+'  Against This Sale'+chr(13)+chr(10)
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform