Je suis un exemple du livre: The Complete Reference C# 3.0 par Herbert Schildt. Il s'agit d'écrire dans Console.WriteLine avec des arguments. Voici l'exemple: J'ai essayé, mais je recevais une erreur:argument erreur C#
Project1.exe has encountered a problem and needs to be close. We are sorry for the inconvenience. Please tell Microsoft about this problem. Send Error Report or Don't Send. And if I click, I get another error in the command prompt. "Unhandled Exception: System.Format.Exception input string was not in a correct format. at System.Text.StringBuilder.AppendFormatError() at System.Text.StringBuilder.AppendFormat(IFormatProvider provider,String Format, Object[]args) at System.IO.TextWriter.WriteLine(String format, Object arg0) at System.IO.TextWriter.SyncTextWriter.WriteLine(String format, Object arg0) At Example2.Main() in D:\myPath
Je ne sais pas si le livre a une erreur ou est-ce mon code? J'apprécierais votre aide. Merci
One of the easiest ways to specify a format is to describe a template that WriteLine() will use. To do this, show an example of the format that you want, using #s to mark the digit positions. You can also specify the decimal point and commas. For example, here is a better way to display 10 divided by 3:
Console.WriteLine("Here is 10/3: {0:#.##}", 10.0/3.0);
The output from this statement is shown here: Here is 10/3: 3.33
BTW ceci est mon code ressemble à:
static void Main()
{
Console.WriteLine("Here is 10/3: {0:#.##)", 10);
}
Salut Lasse V. Karlsen, merci, je l'ai maintenant. oui c'était les accolades. C'était assez simple. Merci – tintincutes