C# Quines

Writing quines is a fun way to while away an afternoon, especially when trying to make them as short as possible. This is the result of my attempt at writing the shortest C# quine possible (155 characters, source file):

class q{static void Main(){string s="class q{{static void Main(){{string s={0}{1}{0};System.Console.Write(s,'{0}',s);}}}}";System.Console.Write(s,'"',s);}}

PS: I came across a shorter C# 3.5 quine (149 characters), which uses var instead of string. Clever. Oh well, c’est la vie.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *