title: C# How to keep do-while loop asking the same question until enter pressed
body: <p>I am a beginner in C# programming and trying to code an app that reads the user input using a do-while loop, however, the loop doesn't continue executing when the user answers the question. I only want the loop to stops when enter is pressed</p>
  <p>This is what I have done so far</p>
  <p>Thanks in advance!</p>
  <pre><code>    //call method to read a text, calculate and display the num of chars
  
      private void ShowStringLength() {
          ConsoleKeyInfo cki;
  
          do
          {
              Console.WriteLine(&quot;Let me calculate the length of strings for you!&quot;);
              Console.WriteLine(&quot;Give me text of any length, or press ENTER to exit!&quot;);
  
              Console.Write(&quot;Enter a string : &quot;);
              String str = Console.ReadLine();
              Console.WriteLine(str.ToUpper());
              int len = str.Length;
              Console.WriteLine(&quot;Numer of Chars is : &quot; + len);
  
              //Reads “Enter” from the keyboard to exit the app
  
              cki = Console.ReadKey();
              Console.Write(&quot;OK. You pressed Enter. See you agian!&quot;);
          } while (cki.Key != ConsoleKey.Enter);
  </code></pre>