nassss

Untitled

Feb 16th, 2020
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. public static string ValidateInput(string title, string description)
  2. {
  3. while (true)
  4. {
  5. Console.WriteLine("Please enter a title:");
  6. try
  7. {
  8. title = ValidateString(Console.ReadLine().ToString());
  9. }
  10. catch (Exception) //ex???
  11. {
  12. Console.WriteLine("Failed to parse title parameter.");
  13. }
  14. if (title.Length < 10 || title.Length > 50)
  15. {
  16. Console.WriteLine("Title should be a string between 10 and 50 symbols.");
  17. continue;
  18. }
  19. else
  20. {
  21. break;
  22. }
  23. }
  24. while (true)
  25. {
  26. Console.WriteLine("Please enter a description:");
  27. try
  28. {
  29. description = ValidateString(Console.ReadLine().ToString());
  30. }
  31. catch (Exception) //ex???
  32. {
  33. Console.WriteLine("Failed to parse description parameter.");
  34. }
  35. if (description.Length < 10 || description.Length > 500)
  36. {
  37. Console.WriteLine("Description should be a string between 10 and 500 symbols.");
  38. continue;
  39. }
  40. else
  41. {
  42. break;
  43. }
  44. }
  45. return "";
  46. }
Advertisement
Add Comment
Please, Sign In to add comment