Advertisement

C# - basic console stuff

Started by December 18, 2002 03:55 AM
3 comments, last by NotAnAnonymousPoster 21 years, 11 months ago
Any idea how I do the equivalent of gotoxy() and getch() in C# with a console program?
"C combines all the power of assembly language with all the ease of use of assembly language"
As far as I know, there is no equivalent of gotoxy() in C#. As far as .NET is concerned, the console is just an input, output and error stream, with no concept of "cursor position".

As for an equivalent to getch(), you can call System.Console.Read() to read a single character.

If I had my way, I''d have all of you shot! codeka.com - Just click it.

Advertisement
To do "gotoxy", you need to P/Invoke the Win32 API functions - as Dean said, .NET doesn''t have a concept of a console beyond input, output and error streams.

See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/console_functions.asp


For those who believe in God, most of the big questions are answered. But for those of us who can''t readily accept the God formula, the big answers don''t remain stone- written. We adjust to new conditions and discoveries. We are pliable. Love need not be a command or faith a dictum. I am my own God. We are here to unlearn the teachings of the church, state, and our educational system. We are here to drink beer. We are here to kill war. We are here to laugh at the odds and live our lives so well that Death will tremble to take us -- Charles Bukowski
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
Have a look at the ConsoleEx example at the GotDotNet site - it does what you want it to do (and a bit more).

http://www.gotdotnet.com/userarea/keywordsrch.aspx?keyword=ConsoleEx


[edited by - BurntToast on December 18, 2002 4:18:55 PM]
Cheers. I''ll give that a go. It''s just for getting some output for the little test programs I''m doing while learning the language.
"C combines all the power of assembly language with all the ease of use of assembly language"

This topic is closed to new replies.

Advertisement