So I'm working on a quiz game application, and one of the things I have to do is use StreamReader to read questions from a text file of the format
Question
Answer1
###Answer 2 (correct answer denoted by ###)
Answer3
Answer4
Question2
Answer1
Answer2
###Answer3
Answer4
and so on. I then have to display the question and said answers on a form, making sure not to display the ###. Basically I'm confused on how I should do this, as our teacher didn't go over StreamReader, and I'm entirely unsure of how I should get it to read a file, return an object, and then use that object to write the text on the form.
public TriviaQuestion ReadQuestion(): reads the input file and returns a new TriviaQuestion object.
And TriviaQuestion is as follows:
namespace QuizGame
{
class TriviaQuestion
{
//attributes
private string question;
private string answerA;
private string answerB;
private string answerC;
private string answerD;
private string correctAnswer;
//properties
public string AnswerA { get; set; }
public string AnswerB { get; set; }
public string AnswerC { get; set; }
public string AnswerD { get; set; }
public string CorrectAnswer { get; set; }
}
}
Any help here?