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!
-
C#のConsole.ResetColor()メソッド
C#のConsole.ResetColor()メソッドは、コンソールの前景色と背景色をデフォルトに設定するために使用されます。 構文 構文は次のとおりです- public static void ResetColor (); 例 ここで、C#でConsole.ResetColor()メソッドを実装する例を見てみましょう- using System; class Demo { public static void Main (string[] args) { Console.WriteLine ("At first
-
C#のConsole.MoveBufferArea()メソッド
C#のConsole.MoveBufferArea()メソッドは、画面バッファーの指定されたソース領域を指定された宛先領域にコピーするために使用されます。 構文 構文は次のとおりです- public static void MoveBufferArea (int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight, int targetLeft, int targetTop); ここで sourceLeft ソース領域の左端の列。 sourceTop ソース領域の一番上の行。 sourceWidt