Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. static void Main(string[] args)
  2. {
  3. Console.WriteLine("Press u0022Enteru0022 to play!");
  4. int num = 0;
  5. void WaitForKey(ConsoleKey key)
  6. {
  7. while (Console.ReadKey(true).Key != key)
  8. {
  9.  
  10. }
  11. }
  12. for (int i = 1; i <= 10; i++)
  13. {
  14. WaitForKey(ConsoleKey.Enter);
  15. Console.Write("{0}", num);
  16. num++;
  17. }
  18. }
  19.  
  20. static void Main(string[] args)
  21. {
  22. Console.WriteLine("Press u0022Enteru0022 to play!");
  23. int num = 0;
  24.  
  25. for (int i = 1; i <= 10; i++)
  26. {
  27. do
  28. {
  29. ConsoleKeyInfo keypress;
  30. ConsoleKeyInfo oldkeypress;
  31.  
  32. keypress = Console.ReadKey(true);
  33. oldkeypress = keypress;
  34.  
  35. keypress = Console.ReadKey(true);
  36. if (oldkeypress != keypress)
  37. {
  38. Console.WriteLine("{0}", num);
  39. num++; ;
  40. oldkeypress = keypress;
  41. }
  42.  
  43. } while (1==1);
  44. }
  45.  
  46. static void Main(string[] args)
  47. {
  48. try
  49. {
  50. Console.WriteLine("Press u0022Enteru0022 to play!");
  51. int num = 0;
  52. for (int i = 1; i <= 10; i++)
  53. {
  54. WaitForKey();
  55. Console.Write("{0}", num);
  56. num++;
  57. }
  58. }
  59. catch (Exception ex)
  60. {
  61. Debug.WriteLine(ex);
  62. }
  63. }
  64. static void WaitForKey()
  65. {
  66. Console.ReadKey(true);
  67. while (!Console.KeyAvailable)
  68. Thread.Sleep(10);
  69. }
  70.  
  71. using System;
  72. using System.Collections.Generic;
  73. using System.IO;
  74. using System.Linq;
  75. using System.Text;
  76. using System.Threading;
  77. using System.Threading.Tasks;
  78.  
  79. namespace ConsoleApp2
  80. {
  81. class Program
  82. {
  83.  
  84. static void Main(string[] args)
  85. {
  86. ConsoleKeyInfo keypress;
  87. ConsoleKeyInfo oldkeypress;
  88.  
  89. keypress = Console.ReadKey(true);
  90. oldkeypress = keypress;
  91. do
  92. {
  93. keypress = Console.ReadKey(true); // read keystrokes
  94. if (oldkeypress != keypress)
  95. { Console.Write(keypress.KeyChar);
  96. oldkeypress = keypress;
  97. }
  98.  
  99. } while (1==1);
  100. }
  101. }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement