I am trying to understand how this piece of self-reproducing code works (found here ), but the problem is that I cannot get it to run as-is :
class c {
static void Main(){
string s = "class c{{static void Main(){{string s={0}{10};System.Console.Write(s,(char)34,s);}}}}";
System.Console.Write(s,(char)34,s);
}
}
It throws an exception in the scenario: The index (based on zero) must be greater than or equal to zero and smaller than the size of the argument list.
Can anyone help - in particular regarding the formatting option {0} {10}?
I worked like this (see below), but it is longer than the original - I am curious how the original could work as in 1st place:
class c {
static void Main(){
string s = "class c{{static void Main(){{string s={0}{1}{2};System.Console.Write(s,(char)34,s,(char)34);}}}}";
System.Console.Write(s,(char)34,s,(char)34);
}
}
source
share