DEV Community


C# and ASCII art

Former Chef turned Full Stack Web Developer and Software Engineer. Currently writing code, cycling, skateboarding, and cooking in the Pacific North West
・2 min read

So I'm starting to learn C#. It's a legendary language and I feel like breaking out of the React path I've been on as soon as I finish building my restaurant POS with React and NextJS. I'll continue the blog following the build out and how to leverage Keystone.ts to build mutations and queries along with some fun tricks I learned from Wes Bos' Advanced React Tutorial.
Today, however, we're starting a new journey, and as such, we're going to cover something kind of simplistic: ASCII art!
I've always been in the dark as to how people made this kind of art. It is defined as the images a computer can create using the 95 ASCII characters defined by the ASCII Standard from 1963 including it's extended proprietary character sets. This all means, we can create cumulative images using our computer's printable characters combined in specific orders.
C# comes with its own console.log method but is better known as it's wordier version
How do we get data displayed in the the console? All we need is Console.WriteLine() and whatever message we want to world to see, like so:
Console.WriteLine("I like Pizza!")
Our love of pizza will be displayed on the console and we can revel in our computer savvy. The artistic capabilities of our WriteLine method are quite a bit more useful than printing out strings. You can create your own ASCII images by printing any combinations of characters, lined up strategically, to produce shapes and even value (the shading from white to black produced with the amount of characters that might overlap or lay adjacent to eachother). Since it's early on in my knowledge of C# and ASCII art, I won't show off my less-than-novice artistic sensibility but you can checkout a ton of examples here
Also, the next time you're hanging out in Visual Studio and need a break from the monotany, give Console.WriteLine a try and start stringing your "strings" together to create your own ASCII art.
Happy coding.

Discussion (0)