C# में Console.Clear विधि का उपयोग कंसोल बफ़र और प्रदर्शन जानकारी की संबंधित कंसोल विंडो को साफ़ करने के लिए किया जाता है।
सिंटैक्स
निम्नलिखित वाक्य रचना है -
public static void 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);
}
} आउटपुट
यह कंसोल का उपयोग करने से पहले निम्नलिखित आउटपुट का उत्पादन करेगा। क्लियर () -
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
उदाहरण
आइए अब कंसोल को लागू करने के लिए वही उदाहरण देखें। विधि साफ़ करें -
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!