0

Do I need to use reflection to write a quine program for C#? I read elsewhere - quine that opening the source file from disk is "cheating" So I guess using .net reflector and/or opening the source file using System.IO is a hack.

Are there other ways other than using Reflection that I should be considering.

Anonymous Type
  • 3,051
  • 2
  • 27
  • 45

1 Answers1

2

Actually you don't need reflection or anything else to make a quine, just a little string manipluation and some time.

using System;      
class Q      
{   
    static void Main()    
    {
        string s = "using System;class Q{2}static void Main(){2}string s ={1}{0}{1};
        Console.Write(string.Format(s, s, (char)34, (char)123, (char)125));{3}{3}";             
        Console.Write(string.Format(s, s, (char)34, (char)123, (char)125));          
    }   
} 

Here is another stack overflow question with a similar theme. The above quine is from here.

Community
  • 1
  • 1
JonVD
  • 4,258
  • 24
  • 24