473,387 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

clear screen from c#

How to clear the screen in the console application in Microsoft Visual C #.
NET 2003.

http://www.alvas.net - Audio tools for C# and VB.Net developers + Christmas
discount
Dec 24 '07 #1
6 12915
Ah; just noticed the 2003... trickier, sorry; perhaps consider
updating? 1.x is getting harder and harder to support daily

Marc
Dec 24 '07 #3
Alexander Vasilevsky wrote:
How to clear the screen in the console application in Microsoft Visual C #.
NET 2003.
Write 25 empty lines.

Or use a hack like:

using System;
using System.Runtime.InteropServices;

class MainClass
{
[DllImport("msvcrt.dll")]
public static extern int system(string cmd);
public static void Main(string[] args)
{
Console.WriteLine("Hello world");
system("CLS");
Console.WriteLine("Hello world");
}
}

Arne
Dec 24 '07 #4
Hi Arne,

>Write 25 empty lines.
Useless if your consoles height is wider
than 25 Lines. So this is no usefull aproach!
And it allocates additional memory you dont
have to do,...you want to free something
and not to allocate more,...

>Or use a hack like:
>using System;
using System.Runtime.InteropServices;
>class MainClass
{
[DllImport("msvcrt.dll")]
public static extern int system(string cmd);
public static void Main(string[] args)
{
Console.WriteLine("Hello world");
system("CLS");
Console.WriteLine("Hello world");
}
}
Its ok, but not needed here. Do not call any
c-runtime functions until there is really a need for
it. Here you can use Marc's suggestion "Console.Clear"
which is just fine.Or use "FillConsoleOutputCharacter" or
"FillConsoleOutputAttribute" with pre-calls
to "GetConsoleScreenBufferInfo" to get the
needed information,...but here you will allocate
extra space for the cleaning memory, so you
dont have to do this,...

CLS is ok, but much better is Console.Clear, since
it is runtime handled!

Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
Dec 25 '07 #5
CLS is ok, but much better is Console.Clear, since
it is runtime handled!

Regards

Kerem
Think someone ment that Clear only handeld in

..NET Framework 3.5, 3.0 SP1, 3.0, 2.0 SP1, 2.0

Went down that way myself... (still missing chr$(12))

//CY
Dec 25 '07 #6
Kerem Gümrükcü wrote:
>Write 25 empty lines.

Useless if your consoles height is wider
than 25 Lines.
Then write some more lines.
Here you can use Marc's suggestion "Console.Clear"
which is just fine.
CLS is ok, but much better is Console.Clear, since
it is runtime handled!
The original poster wrote:

#in Microsoft Visual C # .NET 2003

Marc wrote:

#Console.Clear()

# perhaps consider
#updating? 1.x is getting harder and harder to support daily

Console.Clear is new in 2.0 (2005).
Or use "FillConsoleOutputCharacter" or
"FillConsoleOutputAttribute" with pre-calls
to "GetConsoleScreenBufferInfo" to get the
needed information,
That is a possibility too.

Arne
Dec 26 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: NeoPhreak | last post by:
How would you clearn the screen in a console program??? Thanks NeoPhreak >.<
0
by: Peter | last post by:
I am just trying to learn python, to use for some fairly basic command line utilities which will run in either Windows/DOS or Linux. I cannot find a platform neutral way of manipulating the screen....
20
by: ritchie | last post by:
Hi, I am trying to clear the screen in my program. I am loking for something that will work on all compilers, especially Borland & MS Visual Studio 6. On Visual studio I used 'system("cls");'...
4
by: John | last post by:
Hi I have the following in a Perl script. I just want to "clear screen" but it does not work. I don't think I've got my client and server sides confused. Any ideas? <SCRIPT...
8
by: REDBAIT | last post by:
Hi Guys, Am using Windows 2000 and Dev C++ to create C programs. I'm trying to use clear screen and other graphic functions such as positioning output on screen. Have seen some documents that...
0
by: sajithamol | last post by:
I have an Applet that has three buttons on it, one being a clear screen button. I have it setup right now so it draws a rectangle the size of the applet and fills it with the background color. But...
2
by: owl | last post by:
and here I thought I was going to finally be able to change the world AND contribute back to python with my amazing clear screen extension - but I can't get it to work. ;( Copying from...
9
by: pbd22 | last post by:
Hi. Does anybody know how to issue a clear screen command like DOS "cls" in a telnet session? Thanks!
5
by: Kid Programmer | last post by:
Hello guys. I was wondering how you can clear the screen in a java program. Here is the code for my program: import javax.swing.SwingUtilities; import javax.swing.JFrame; import...
1
by: sganeshsvk | last post by:
i want to clear the screen command prompt for mysql in windows XP... In linux we use (CTRL + L) for clear the screen in mysql prompt.... i already use this command ( \c ) then ( \! clear ) for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.