Quantcast
Channel: Active questions tagged return-value - Stack Overflow
Viewing all articles
Browse latest Browse all 210

TwitchLib in C# crashes after return values

$
0
0

I wrote my program with many global variables and only with public void methods.So I want to change my methods to private static methods with return values. That's what I've done.

Now my program will only pass once through "globalChatMessageReceived" of TwitchLib and then it does nothing at all. No problems or errors will display and the program is running correctly and saves data but it will only doing this once.

I am using

FindPokemonName(MessageSplitForPokemonName[1]);

without return values and

(string[] PokedexName, Boolean ChosenPokemonIsAvailable, Boolean ChosenPokemonIsNoStarter, string NameOfChosenPokemon) = FindPokemonName(MessageSplitForPokemonName[1]);

with return values.

Here is the code with global variables and no return values:

        public void FindTrainerID(string TrainerID, string ChatDisplayName)        {            TrainerVorhanden = false;            if (File.Exists(@"C:\txt\trainer\" + TrainerID +".txt"))            {                string FoundTrainer = File.ReadAllText(@"C:\txt\trainer\" + TrainerID +".txt");                Trainer = FoundTrainer.Split('\\');                TrainerVorhanden = true;            }        }

And that's what I've done now with return values:

        private static (string[] Trainer, bool TrainerAvailable) FindTrainerID(string TrainerID)        {            string[] Trainer = new string[5];            Boolean TrainerAvailable = false;            if (File.Exists(@"C:\txt\trainer\" + TrainerID +".txt"))            {                string FoundTrainer = File.ReadAllText(@"C:\txt\trainer\" + TrainerID +".txt");                Trainer = FoundTrainer.Split('\\');                TrainerAvailable = true;            }            return (Trainer, TrainerAvailable);        }

I tried the program without using the methods with a return value. The program is running constantly with the TwitchLib method "globalChatMessageReceived".

If I'm using return values it does nothing after that.


Viewing all articles
Browse latest Browse all 210

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>