Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.30 KB | None | 0 0
  1. public static int ReadInt(string line, Predicate<int> pr)
  2.         {
  3.             int x; do
  4.             {
  5.                 Console.Write(line);
  6.  
  7.             } while (!int.TryParse(Console.ReadLine(), out x) || !pr(x));
  8.             return x;
  9.         }
  10.  
  11. int n = ReadInt("N= ", x => (x > 0) & (x < 25));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement