Computer >> 컴퓨터 >  >> 프로그램 작성 >> C#

C#의 Console.Clear 메서드

<시간/>

C#의 Console.Clear 메서드는 표시 정보의 콘솔 버퍼와 해당 콘솔 창을 지우는 데 사용됩니다.

구문

다음은 구문입니다 -

public static void Clear ();

예시

이제 Console.Clear 메서드를 구현하기 전에 예를 살펴보겠습니다. -

using System;
public class Demo {
   public static void Main(){
      Uri newURI1 = new Uri("https://www.tutorialspoint.com/");
      Console.WriteLine("URI = "+newURI1);
      Console.WriteLine("String representation = "+newURI1.ToString());
      Uri newURI2 = new Uri("https://www.tutorialspoint.com/jquery.htm#abcd");
      Console.WriteLine("\nURI = "+newURI2);
      Console.WriteLine("String representation = "+newURI2.ToString());
      if(newURI1.Equals(newURI2))
         Console.WriteLine("\nBoth the URIs are equal!");
      else
         Console.WriteLine("\nBoth the URIs aren't equal!");
      Uri res = newURI1.MakeRelativeUri(newURI2);
      Console.WriteLine("Relative uri = "+res);
}
}

출력

이것은 Console.Clear()를 사용하기 전에 다음과 같은 출력을 생성합니다 -

URI = https://www.tutorialspoint.com/
String representation = https://www.tutorialspoint.com/
URI = https://www.tutorialspoint.com/jquery.htm#abcd
String representation = https://www.tutorialspoint.com/jquery.htm#abcd
Both the URIs aren't equal!
Relative uri = jquery.htm#abcd

예시

이제 Console.Clear 메서드를 구현하는 동일한 예를 살펴보겠습니다. -

using System;
public class Demo {
   public static void Main(){
      Uri newURI1 = new Uri("https://www.tutorialspoint.com/");
      Console.WriteLine("URI = "+newURI1);
      Console.WriteLine("String representation = "+newURI1.ToString());
      Uri newURI2 = new Uri("https://www.tutorialspoint.com/jquery.htm#abcd");
      Console.WriteLine("\nURI = "+newURI2);
      Console.WriteLine("String representation = "+newURI2.ToString());
      if(newURI1.Equals(newURI2))
         Console.WriteLine("\nBoth the URIs are equal!");
      else
         Console.WriteLine("\nBoth the URIs aren't equal!");
      Uri res = newURI1.MakeRelativeUri(newURI2);
      Console.WriteLine("Relative uri = "+res);
      Console.Clear();
      Console.WriteLine("Console cleared now!");
   }
}

출력

이것은 다음과 같은 출력을 생성합니다 -

Console cleared now!