S
S
sulim0003332018-12-15 16:06:33
C++ / C#
sulim000333, 2018-12-15 16:06:33

Why doesn't string to number conversion work?

What's wrong here?

using System;

namespace DefaultProject
{
  class MainClass
  {
    public static void Main (string[] args)
    {
      string str = "100";
      string str1 = Console.ReadLine ();
      int x = Convert.ToInt32 (str);
      Console.WriteLine (x + str1);
      Console.ReadKey ();
    }
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Satisfied IT, 2018-12-15
@sulim000333

string str = "100";you turn this line into a number here int x = Convert.ToInt32(str);, and string str1 = Console.ReadLine()you plan to translate the line into a number? Or should it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question