jeudi 25 août 2016

How to split string Error

Why does this console application not work, its very simple. It only returns the word 'Hello' and wont move onto the word 'Bill'. It works by typing

Any tips or fixes would be awesome!

       static void Main(string[] args)
    {
        //Varaibles and Condition Types
        string WordiIntitalString = Console.ReadLine();
        //outputs "hello bill"
        char[] delimiterChars = { ' ' };
        string[] WordArray = WordiIntitalString.Split(delimiterChars);
        foreach(var word in WordArray)
        {
            //Console.WriteLine(word);
            if (word.Equals("hello"))
            {
                Console.WriteLine(word);
                Thread.Sleep(1000);
                if (word.Contains("bill"))
                {
                    Console.WriteLine("jarvis");
                    Thread.Sleep(1000);
                }
            }
            Thread.Sleep(1000);
        }

Aucun commentaire:

Enregistrer un commentaire