Ich mache ein Beispiel aus dem Buch: Die komplette Referenz C# 3.0 von Herbert Schildt. Es geht darum, in Console.WriteLine mit Argumenten zu schreiben. Hier ist das Beispiel: Ich versuche dies aber ich war immer eine Fehlermeldung:Argument Fehler 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
Ich bin nicht sicher, ob das Buch fehlerhaft oder ist es mein Code? Ich würde Ihre Hilfe zu schätzen wissen. Dank
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 dies ist mein Code wie folgt aussieht:
static void Main()
{
Console.WriteLine("Here is 10/3: {0:#.##)", 10);
}
Hallo Lasse V. Karlsen, danke ich habe es jetzt bekommen. Ja, es waren die geschweiften Klammern. Das war ziemlich einfach. Danke – tintincutes