mercredi 6 janvier 2016

C# Code is skipping ELSE IF statement

i have an IF/ELSEIF/ELSE statement, there are 8 ELSEIF statements, but I think its skipping the last one. I have some dictionaries, and the last ELSEIF checks if a value of a dictionary contains what the user inputted, it is, but i don't know why it isn't working.

else if (cmdpackages.ContainsValue(cmd))
{
    string lcl;
    string code;
    invcmdpackages.TryGetValue(cmd, out lcl);
    packagescode.TryGetValue(lcl, out code);
    WriteLine("Raw code: " + code);

}

In the program, when I input an specific command, it downloads a string from a webpage (raw.githubusercontent.com...) and saves all the data in the string in different dictionaries.

This are all the Dictionaries needed: packagesin, Key: ID, Value: Package name cmdpackages, Key: Package name, Value: Command invcmdpackages, Key: Command, Value: Package name packagescode, Key: Package name, Value: Code

This statement checks if the user input is the same to a command in cmdpackages, if true, gets the Package name using TryGetValue in invcmdpackages, and with it, gets the code to parse inside the statement using TryGetValue in packagescode. Now, it's supposed to write in console: "Raw code: " + the code to parse. This is just for debugging.

Let's say the command for downloading the string is "downl". Then, the user writes in "downl packagename". Joins an URL pattern with the packagename, and tries to download, all code is fine and the package exists in the repo. Saves all data in the dictionaries and gets back triggering user input. Now, when i input "packagecommand", which can be the command that packagename responds too, checks if its contained in cmdpackages, but for any reason, says not, directly goes to the next statement (ELSE) and restarts the loop.

Thanks, TheCrimulo.

Aucun commentaire:

Enregistrer un commentaire