2
The following code will produce a run-time error, stackoverflow
exception.
class Foo
{
//static Foo foo = new Foo(); // you are not allowed using this approach
//static readonly Foo foo = new Foo(); // you are not allowed using this approach
Foo foo = new Foo();
}
class Program
{
static void Main(string[] args)
{
new Foo();
}
}
The objective is to cancel the exception without
- removing, modifying or commenting out the existing code,
- using the approaches mentioned (and their variants in access modifiers,
public
,private
, etc) as the given comments, - using
try-catch-finally
or its variants, - using attributes,
- using compilation condition,
You are only allowed to add your own code inside the Foo
class. How do you cancel the exception at run-time?
It would be best to tag this question as either [tag:popularity-contest] or [tag:code-golf] so it's clear how you will objectively declare a winner. – Darren Stone – 2014-01-06T01:51:45.580
I probably will add more rules if your ideas are too trivial. Sorry for this inconvenience. – kiss my armpit – 2014-01-06T02:02:56.553
5Pulling the rug out like that may be considered rude. It's best to think your question through thoroughly before asking the internet to spend effort on it. :-) – Darren Stone – 2014-01-06T02:10:37.430
1This is a [tag:popularity-contest] yet the accepted answer has few votes. You should accept the highest-voted answer (see [tag:popularity-contest]) – Justin – 2014-01-10T03:43:14.093
1@Quincunx: I changed the tag. – kiss my armpit – 2014-01-10T03:58:49.283
You need winning criterion (?) – Timtech – 2014-12-01T13:20:16.907