Console.Clear() 메서드를 사용하여 화면과 콘솔 버퍼를 지웁니다. Clear 메서드가 호출되면 커서가 자동으로 창의 왼쪽 상단으로 스크롤됩니다.
여기에서 화면을 지운 다음 ForegroundColor 및 BackgroundColor -
를 설정했습니다.ConsoleColor newForeColor = ConsoleColor.Blue; ConsoleColor newBackColor = ConsoleColor.Yellow;
다음은 완전한 코드입니다 -
예
using System;
using System.Collections.Generic;
class Program {
static void Main() {
ConsoleColor foreColor = Console.ForegroundColor;
ConsoleColor backColor = Console.BackgroundColor;
Console.WriteLine("Clearing the screen!");
Console.Clear();
ConsoleColor newForeColor = ConsoleColor.Blue;
ConsoleColor newBackColor = ConsoleColor.Yellow;
}
} 출력
Clearing the screen!