Error Converting String to Int
-
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
-
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
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...
-
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