none
Simple Simple Simple but still Exception. Frustrating. RRS feed

  • Question

  • Hello,

    I am testing simple code. The build works fine but I get the exception below when I run this:

    using System;
    namespace Variables
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("{0} {1)", byte.MinValue, byte.MaxValue);
            }
        }
    }

    Unhandled Exception: System.FormatException: Input string was not in a correct format.
       at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
       at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
       at System.IO.TextWriter.WriteLine(String format, Object arg0, Object arg1)
       at System.IO.TextWriter.SyncTextWriter.WriteLine(String format, Object arg0, Object arg1)
       at System.Console.WriteLine(String format, Object arg0, Object arg1)
       at Variables.Program.Main(String[] args) in C:\Users\admin\source\repos\Variables\Variables\Program.cs:line 9

    It looks exactly the same as it appears in the training I made it from.  Any ideas?

    Friday, May 4, 2018 1:26 AM

Answers

  • Carefully look at:

    //Console.WriteLine("{0} {1)", byte.MinValue, byte.MaxValue);
    Console.WriteLine("{0} {1}", byte.MinValue, byte.MaxValue);
    Missing right } parenthesis.

    Best Regards
    Vikram Manjare
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Friday, May 4, 2018 1:40 AM
  • Hello,

    I am testing simple code. The build works fine but I get the exception below when I run this:

    using System;
    namespace Variables
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("{0} {1)", byte.MinValue, byte.MaxValue);
            }
        }
    }

    Unhandled Exception: System.FormatException: Input string was not in a correct format.
       at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
       at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
       at System.IO.TextWriter.WriteLine(String format, Object arg0, Object arg1)
       at System.IO.TextWriter.SyncTextWriter.WriteLine(String format, Object arg0, Object arg1)
       at System.Console.WriteLine(String format, Object arg0, Object arg1)
       at Variables.Program.Main(String[] args) in C:\Users\admin\source\repos\Variables\Variables\Program.cs:line 9

    It looks exactly the same as it appears in the training I made it from.  Any ideas?

    Here's a better way to code that:

     Console.WriteLine($"{byte.MinValue} {byte.MaxValue}");
    

    Sunday, May 6, 2018 7:59 PM

All replies

  • Carefully look at:

    //Console.WriteLine("{0} {1)", byte.MinValue, byte.MaxValue);
    Console.WriteLine("{0} {1}", byte.MinValue, byte.MaxValue);
    Missing right } parenthesis.

    Best Regards
    Vikram Manjare
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Friday, May 4, 2018 1:40 AM
  • Thank you very much!  A big help to me.  I really appreciate it!!  Have a great day!
    Friday, May 4, 2018 3:07 AM
  • Hello,

    I am testing simple code. The build works fine but I get the exception below when I run this:

    using System;
    namespace Variables
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("{0} {1)", byte.MinValue, byte.MaxValue);
            }
        }
    }

    Unhandled Exception: System.FormatException: Input string was not in a correct format.
       at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
       at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
       at System.IO.TextWriter.WriteLine(String format, Object arg0, Object arg1)
       at System.IO.TextWriter.SyncTextWriter.WriteLine(String format, Object arg0, Object arg1)
       at System.Console.WriteLine(String format, Object arg0, Object arg1)
       at Variables.Program.Main(String[] args) in C:\Users\admin\source\repos\Variables\Variables\Program.cs:line 9

    It looks exactly the same as it appears in the training I made it from.  Any ideas?

    Here's a better way to code that:

     Console.WriteLine($"{byte.MinValue} {byte.MaxValue}");
    

    Sunday, May 6, 2018 7:59 PM
  • Thanks!
    Sunday, May 6, 2018 9:38 PM