Advertisement
Guest User

Code

a guest
Jul 17th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp1
  8. {
  9. public class FlashCard
  10. { //class open
  11. public string question;
  12. public string answer;
  13. public string userinput;
  14.  
  15.  
  16. public void Create()
  17. { //create open
  18. Console.WriteLine("Enter your question");
  19. question = Console.ReadLine();
  20. Console.WriteLine("What is the answer to the question?");
  21. answer = Console.ReadLine();
  22.  
  23. } //create close
  24.  
  25. public override string ToString()
  26. { //string to string open
  27. // using StringBuilder here just because it's more performant than normal string concatenation
  28. var stringBuilder = new StringBuilder();
  29.  
  30. stringBuilder.AppendLine("Flashcard");
  31. stringBuilder.AppendLine("------------------------------------");
  32. stringBuilder.AppendLine("Q: " + question);
  33. stringBuilder.AppendLine("A: " + answer);
  34. stringBuilder.AppendLine("UserInput: " + userinput);
  35.  
  36. // You can see that StringBuilder also uses its own implementation for ToString() that does the performant concatenation.
  37. return stringBuilder.ToString();
  38. } //string to string close
  39. } //class close
  40.  
  41.  
  42. } //namespace close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement