开发者

Is the reflection namespace a building block for writing a quine in C#?

开发者 https://www.devze.com 2023-01-22 03:46 出处:网络
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\"

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 o开发者_开发问答pening the source file using System.IO is a hack.

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消