0

i am a kind of young, and i just started coding yesterday. So i am getting some practice in coding and making a new project (console application) that opens different apps depending on which number the user enters, but the problem is get "Input string was not in a correct format." whenever i try to run an app through my project, can someone help me? (also the extra part of code at the bottom is the part i get an error on, i dont really know how to use stack over flow)

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Globalization;
using System.ComponentModel.Design;
using System.Security.Cryptography;
using System.Security.Policy;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Net;
using System.Configuration;
using System.Diagnostics;

namespace Nuzuki_v3
{
    class Program
    {
        static void Main(string[] args)
        {
        st:
            Console.Write("Would you like to log in: ");
            string b = Console.ReadLine();
            if (b != "yes" && b != "no")
            {
                Console.WriteLine("Yes or No");
                Thread.Sleep(1000);
                Console.Clear();
                goto st;
            }
            Console.Write("Username: ");
            string sus = Console.ReadLine();
            Console.Write("Password: ");
            string red = Console.ReadLine();

            if (sus == "multi" && red == "tool")
            {
                goto rav;
            }
            if (sus != "multi" && red != "tool")
            {
                Console.WriteLine("Wrong login");
                Thread.Sleep(1000);
                Console.Clear();
                goto st;
            }
            
            rav: Console.WriteLine("What are you here for? ");
            string lol = Console.ReadLine();
            if (lol == "root")
            {
                Console.WriteLine("Are you sure kid, you are kinda young");
                string retard = Console.ReadLine();
                if (retard == "yes")
                {
                    Console.WriteLine("Ok kid.. goodluck");
                    Thread.Sleep(2000);
                    Console.Clear();

                }
                goto start;
            }
            else
            {
                lol:
                Console.WriteLine("What is your name?");
                string name1 = Console.ReadLine();
                Console.WriteLine("Well " + name1 + " you are in the wrong place kid");
                Thread.Sleep(1000);
                goto st;
            }
            start: 
            Console.WriteLine("███▄    █  █    ██ ▒███████▒ █    ██  ██ ▄█▀ ██▓ ");
            Console.WriteLine(" ██ ▀█   █  ██  ▓██▒▒ ▒ ▒ ▄▀░ ██  ▓██▒ ██▄█▒ ▓██▒    1-Lanc Remastered           9-Credits        ");
            Console.WriteLine("▓██  ▀█ ██▒▓██  ▒██░░ ▒ ▄▀▒░ ▓██  ▒██░▓███▄░ ▒██▒    2-pScan                     10-Vebdex        ");
            Console.WriteLine("▓██▒  ▐▌██▒▓▓█  ░██░  ▄▀▒   ░▓▓█  ░██░▓██ █▄ ░██░    3-LOIC                      11-Stressthem.to ");
            Console.WriteLine("▒██░   ▓██░▒▒█████▓ ▒███████▒▒▒█████▓ ▒██▒ █▄░██░    4-HOIC                      12-Sick Fonts    ");
            Console.WriteLine("░ ▒░   ▒ ▒ ░▒▓▒ ▒ ▒ ░▒▒ ▓░▒░▒░▒▓▒ ▒ ▒ ▒ ▒▒ ▓▒░▓      5-IP Pinger                 13-Among Us Hacks");
            Console.WriteLine("░ ░░   ░ ▒░░░▒░ ░ ░ ░░▒ ▒ ░ ▒░░▒░ ░ ░ ░ ░▒ ▒░ ▒ ░    6-Username Sherlock         14-My discord server");
            Console.WriteLine("   ░   ░ ░  ░░░ ░ ░ ░ ░ ░ ░ ░ ░░░ ░ ░ ░ ░░ ░  ▒ ░    7-IP Lookup                 15-Fake info gen  ");
            Console.WriteLine("         ░    ░       ░ ░       ░     ░  ░    ░      8-IP Logger                 16-Fortnite hacks ");
            Console.WriteLine("                    ░                               ");
            int nano = Console.Read();
            nano = int.Parse(Console.ReadLine());
            if (nano == 1)
            {
                Process lanc = new Process();
                lanc.StartInfo.FileName = "LANC_Remastered.exe";
                lanc.StartInfo.Arguments = "LANC_Remastered.exe";
                lanc.Start();
            }

            if (b == "no")
            {
                Console.WriteLine("Ok well.. bye");
                Thread.Sleep(1000);
                Environment.Exit(1);
            }


        }

    }
         int nano = Console.Read();
            nano = int.Parse(Console.ReadLine());
            if (nano == 1)
            {
                Process lanc = new Process();
                lanc.StartInfo.FileName = "LANC_Remastered.exe";
                lanc.StartInfo.Arguments = "LANC_Remastered.exe";
                lanc.Start();
Nuzuki
  • 1
  • 2
    When you post, it's better to create a [mcve] (a minimal reproducible example). Most of the code you have provided doesn't relate to your problem. In this case it's pretty obvious where the issue will lie, so it was easy to search for it, but in future it's better to post as little code as possible to fully demonstrate the issue. – ProgrammingLlama Oct 17 '20 at 05:40
  • I strongly recommend to avoid the use of `goto` by all means. It makes program logic very hard to follow. – Klaus Gütter Oct 17 '20 at 05:42
  • Essentially your issue is this: `int.Parse` will try to validate the string it receives. By default, if the string is not an integer (a whole number) or contains anything other than digits, it will fail and throw the "Input string was not in the correct format" exception. An empty string will fail, `" 10"` will fail, etc. because `""` isn't a number, and `" 10"` contains a space, etc. As the duplicates suggest, you should use `TryParse` instead of `Parse`. – ProgrammingLlama Oct 17 '20 at 05:43
  • [`TryParse` docs and examples](https://learn.microsoft.com/en-us/dotnet/api/system.int32.tryparse?view=netcore-3.1#System_Int32_TryParse_System_String_System_Int32__) – ProgrammingLlama Oct 17 '20 at 05:45

0 Answers0