-2

C# windows application
I want the code to be like this:
1-receive a text and 2-show caps lock is on or not, at the same time.

Please fix this? Thanks.

using System;

namespace ConsoleApplication89
{
    class Program
    {          
        static void Main(string[] args)
        {
            Console.Title = "Pasword";

            while (Console.ReadKey().Key != ConsoleKey.Enter)
            {
                int origRow = Console.CursorTop;
                int origCol = Console.CursorLeft;
                Console.SetCursorPosition(60, 23);
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("CapsLock = " + (Console.CapsLock));
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.SetCursorPosition(origCol, origRow);
            }
            string A = Console.ReadLine();
            Console.WriteLine("Password entered =" + A); 
       }
    }
}
Theodor Zoulias
  • 34,835
  • 7
  • 69
  • 104
  • 1
    Fix what? You haven't explained the actual problem you have with your code – UnholySheep Aug 31 '23 at 12:06
  • 1
    OP could you rewrite your question to explain what you want? I think you're saying that you want to read the password input while keeping the "CapsLock = true/false" readout up to date while the user is typing - is that correct? If so please could you update your question to make that clear – John Aug 31 '23 at 12:11
  • Your code looks like a Console application, not a Windows Forms application. – Theodor Zoulias Aug 31 '23 at 12:18

0 Answers0