After logging so much into the console. We would need to clear it up for further use. For that Console.Clear() method is used. The Console.Clear() method is used to clear the console history. In other words, this method removes previously printed messages. After clearing the console this method writes “Console was cleared” in the console.
What we discussed above is given in the below example.
Output: Run the above code, and then press the F12 key and go to the Console tab as shown in the below image.