Click here to Skip to main content
15,891,785 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am completely new to C# and am using the need to print a simple graphic (lines and text) from a command line application to learn something about C#. This program will read a data file and generate the graphic line by line.
Everything that I have found seems incomplete in some form and will not compile error free. Is there a complete example of code which can print from C# and is complete - will compile error free. I would like to have a know quantity to get started with this.

What I have tried:

Microsoft examples. None seem to be even close to an error free compile.
Posted
Updated 14-Apr-20 11:34am
Comments
Ravi Bhavnani 14-Apr-20 13:26pm    
Mark, by "print" do you mean "output to the console"? If so, see Console.WriteLine().

/ravi

If you want to print to a printer see the example here: PrintDocument.Print Method (System.Drawing.Printing) | Microsoft Docs[^]
 
Share this answer
 
If you mean to a printer, then Rick has it covered for you.
If you mean to try and print graphics that the user can see on the screen, the a Console is not the solution you want - and that is probably why none of the solutions you have tried will compile: they are not designed for console based applications, and will not compile (or work) in that environment. A Console is a text-based environment, and does not support graphics, even simple lines are pretty much beyond it's capabilities.

If you are learning, the I'd strongly suggest that you go back a few chapters in your book, or review a couple of lessens worth of course notes - you seem to have missed something really important alone the way!
 
Share this answer
 
Comments
Richard Deeming 16-Apr-20 9:07am    
"even simple lines are pretty much beyond it's capabilities"

Are you sure about that? :)
GitHub - migueldeicaza/gui.cs: Console-based user interface toolkit for .NET applications.[^]
OriginalGriff 16-Apr-20 9:09am    
That's why the "pretty much" was in there - now use it to draw a rounded corner ... :laugh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900