Computer >> 컴퓨터 >  >> 프로그래밍 >> C#

C#에서 콘솔 CursorSize(커서 크기)를 변경하는 방법

C#에서 콘솔(Console)의 커서 크기를 변경하려면 Console.CursorSize 속성을 사용하면 됩니다. 이 속성은 콘솔 화면에 표시되는 커서의 두께를 조절하며, 값은 1(얇은 커서)부터 100(전체 높이 블록 커서) 사이로 설정할 수 있습니다.

예제

다음 예제를 통해 CursorSize 속성의 사용 방법을 살펴보겠습니다.

using System;
class Demo {
   public static void Main (string[] args) {
      Console.BackgroundColor = ConsoleColor.Blue;
      Console.WriteLine("Background color changed = "+Console.BackgroundColor);
      Console.ForegroundColor = ConsoleColor.Yellow;
      Console.WriteLine("\nForeground color changed = "+Console.ForegroundColor);
      Console.CursorSize = 1;
      Console.WriteLine("\nCursorSize = "+Console.CursorSize);
   }
}

출력 결과

위 코드를 실행하면 다음과 같은 출력 결과가 나타납니다.

C#에서 콘솔 CursorSize(커서 크기)를 변경하는 방법