[nfbcs] Trivia game help

Taylor Arndt taylorarndt99 at gmail.com
Tue Apr 18 16:03:44 UTC 2017


Hi, so i am making a trivia game in c#. I have a sample question in an
array, but i can't seem to get so that it will check if it is correct.
It keeps reading the text file and won't check if answer is correct.
Here is my code
 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;




namespace Trivia_Game
{
    class Program
    {
        private object questionArray;
        private object stringquestion;
        private object stringcorrectAnswer;
        private object question;
        private object userAnswer;
        private int credit;
        private static int score;
        private static object correctAnswer;
        private static string stringuserAnswer;
        private static bool user;
        private static int i;
        private static string dataFile;
        private static string[] shuffledLines;
        private static object file;
        private static string Key;
        private static object reader;
        private static object Reader;
        private static object streamReader;
        private static FileStream fileStream;
        private static object questionIndex;

        public static object QuestionArray { get; private set; }

        static void Main(string[] args)
        {
            Console.WriteLine("Enter your answer");


            string[] lines = File.ReadAllLines("questions.txt", Encoding.UTF8);

            string AnswerEntered;
            AnswerEntered = Console.ReadLine();

            foreach (string line in lines)
            {
                string[] questions = new string[1] { "What was the
version number of ios that introduced voiceover?" };
                string[] CorrectAnswer = new string[1] { "A"};
                Console.WriteLine(line);
                Console.WriteLine("Enter an answer");

                AnswerEntered= Console.ReadLine();

                string[] IncorrectAnswer=new string [1] {"B"};

                if(AnswerEntered=="CorrectAnswer")

                {
                    Console.WriteLine("You are correct!");
                }

                Console.ReadLine();

            }
        }



    }

}





-- 
Taylor




More information about the NFBCS mailing list