Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Error Converting String to Int

Error Converting String to Int

Scheduled Pinned Locked Moved C#
csharphelplounge
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Broodje Games
    wrote on last edited by
    #1

    Hi, Im working in C# and trying to get string[] to int when I get an error: My code: string htmlCodee = Client.DownloadString("http://tf2casino.cf/prices/key.txt"); string[] htmlCode = htmlCodee.Replace("\r", "").Split('\n'); int low = Convert.ToInt32(htmlCode[1]); My error: ERROR: System.FormatException: De indeling van de invoertekenreeks is onjuist. bij System.Number.StringToNumber(String str, NumberStyles options, NumberBuff er& number, NumberFormatInfo info, Boolean parseDecimal) bij System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo i nfo) bij System.Convert.ToInt32(String value) bij SteamBot.SimpleUserHandler.PriceUpdate() in c:\Users\Gebruiker\Documents\ Bot\KeyBot\SteamBot\SimpleUserHandler.cs:regel 136 bij SteamBot.SimpleUserHandler.OnLoginCompleted() in c:\Users\Gebruiker\Docum ents\Bot\KeyBot\SteamBot\SimpleUserHandler.cs:regel 107 bij SteamBot.Bot.b__5(LoginKeyCallback callback) in c:\Us ers\Gebruiker\Documents\Bot\KeyBot\SteamBot\Bot.cs:regel 436 bij SteamKit2.CallbackMsgExtensions.Handle[T](ICallbackMsg msg, Action`1 hand ler) bij SteamBot.Bot.HandleSteamMessage(ICallbackMsg msg) in c:\Users\Gebruiker\D ocuments\Bot\KeyBot\SteamBot\Bot.cs:regel 416 bij SteamBot.Bot.BackgroundWorkerOnDoWork(Object sender, DoWorkEventArgs doWo rkEventArgs) in c:\Users\Gebruiker\Documents\Bot\KeyBot\SteamBot\Bot.cs:regel 89 6 (Sorry for random NL text between it) -Greetings, Jonathan

    OriginalGriffO M 2 Replies Last reply
    0
    • B Broodje Games

      Hi, Im working in C# and trying to get string[] to int when I get an error: My code: string htmlCodee = Client.DownloadString("http://tf2casino.cf/prices/key.txt"); string[] htmlCode = htmlCodee.Replace("\r", "").Split('\n'); int low = Convert.ToInt32(htmlCode[1]); My error: ERROR: System.FormatException: De indeling van de invoertekenreeks is onjuist. bij System.Number.StringToNumber(String str, NumberStyles options, NumberBuff er& number, NumberFormatInfo info, Boolean parseDecimal) bij System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo i nfo) bij System.Convert.ToInt32(String value) bij SteamBot.SimpleUserHandler.PriceUpdate() in c:\Users\Gebruiker\Documents\ Bot\KeyBot\SteamBot\SimpleUserHandler.cs:regel 136 bij SteamBot.SimpleUserHandler.OnLoginCompleted() in c:\Users\Gebruiker\Docum ents\Bot\KeyBot\SteamBot\SimpleUserHandler.cs:regel 107 bij SteamBot.Bot.b__5(LoginKeyCallback callback) in c:\Us ers\Gebruiker\Documents\Bot\KeyBot\SteamBot\Bot.cs:regel 436 bij SteamKit2.CallbackMsgExtensions.Handle[T](ICallbackMsg msg, Action`1 hand ler) bij SteamBot.Bot.HandleSteamMessage(ICallbackMsg msg) in c:\Users\Gebruiker\D ocuments\Bot\KeyBot\SteamBot\Bot.cs:regel 416 bij SteamBot.Bot.BackgroundWorkerOnDoWork(Object sender, DoWorkEventArgs doWo rkEventArgs) in c:\Users\Gebruiker\Documents\Bot\KeyBot\SteamBot\Bot.cs:regel 89 6 (Sorry for random NL text between it) -Greetings, Jonathan

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Start by using the debugger and looking at the data you have downloaded from the file: what exactly does it contain? Then look at the array content post-split: what is in the second array element, exactly? The chances are that the data is not what you expect, and the "second line" does not contain just a number. But we can't check that for you!

      Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      • B Broodje Games

        Hi, Im working in C# and trying to get string[] to int when I get an error: My code: string htmlCodee = Client.DownloadString("http://tf2casino.cf/prices/key.txt"); string[] htmlCode = htmlCodee.Replace("\r", "").Split('\n'); int low = Convert.ToInt32(htmlCode[1]); My error: ERROR: System.FormatException: De indeling van de invoertekenreeks is onjuist. bij System.Number.StringToNumber(String str, NumberStyles options, NumberBuff er& number, NumberFormatInfo info, Boolean parseDecimal) bij System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo i nfo) bij System.Convert.ToInt32(String value) bij SteamBot.SimpleUserHandler.PriceUpdate() in c:\Users\Gebruiker\Documents\ Bot\KeyBot\SteamBot\SimpleUserHandler.cs:regel 136 bij SteamBot.SimpleUserHandler.OnLoginCompleted() in c:\Users\Gebruiker\Docum ents\Bot\KeyBot\SteamBot\SimpleUserHandler.cs:regel 107 bij SteamBot.Bot.b__5(LoginKeyCallback callback) in c:\Us ers\Gebruiker\Documents\Bot\KeyBot\SteamBot\Bot.cs:regel 436 bij SteamKit2.CallbackMsgExtensions.Handle[T](ICallbackMsg msg, Action`1 hand ler) bij SteamBot.Bot.HandleSteamMessage(ICallbackMsg msg) in c:\Users\Gebruiker\D ocuments\Bot\KeyBot\SteamBot\Bot.cs:regel 416 bij SteamBot.Bot.BackgroundWorkerOnDoWork(Object sender, DoWorkEventArgs doWo rkEventArgs) in c:\Users\Gebruiker\Documents\Bot\KeyBot\SteamBot\Bot.cs:regel 89 6 (Sorry for random NL text between it) -Greetings, Jonathan

        M Offline
        M Offline
        miki bgd
        wrote on last edited by
        #3

        I saw the file, and i suppose you get these 2 strings: "15.66" "15.88" Those strings hold double value, and you get exception because of that. Greetings

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups