Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- public class FlashCard
- { //class open
- public string question;
- public string answer;
- public string userinput;
- public void Create()
- { //create open
- Console.WriteLine("Enter your question");
- question = Console.ReadLine();
- Console.WriteLine("What is the answer to the question?");
- answer = Console.ReadLine();
- } //create close
- public override string ToString()
- { //string to string open
- // using StringBuilder here just because it's more performant than normal string concatenation
- var stringBuilder = new StringBuilder();
- stringBuilder.AppendLine("Flashcard");
- stringBuilder.AppendLine("------------------------------------");
- stringBuilder.AppendLine("Q: " + question);
- stringBuilder.AppendLine("A: " + answer);
- stringBuilder.AppendLine("UserInput: " + userinput);
- // You can see that StringBuilder also uses its own implementation for ToString() that does the performant concatenation.
- return stringBuilder.ToString();
- } //string to string close
- } //class close
- } //namespace close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement