There is no restriction on the REAL programming language. For VB.NET and Java, I would be shocked if there is any limit. The limit will NOT be memory, because we are talking about COMPILE TIME constraints, not environment constraints.
This only works in C #: It should be noted that the compiler can optimize this so as not to even use IF.
static void Main(string[] args) { if (true) { if (true) { if (true) { if (true) { if (true) { if (true) { if (true) { if (true) { if (true) { if (true) { if (true) { if (true) { if (true) { if (true) { Console.WriteLine("It works"); } } } } } } } } } } } } } } }
This should not be too optimized:
static void Main(string[] args) { if (DateTime.Now.Month == 1) { if (DateTime.Now.Year == 2011) { if (DateTime.Now.Month == 1) { if (DateTime.Now.Year == 2011) { if (DateTime.Now.Month == 1) { if (DateTime.Now.Year == 2011) { if (DateTime.Now.Month == 1) { if (DateTime.Now.Year == 2011) { if (DateTime.Now.Month == 1) { if (DateTime.Now.Year == 2011) { if (DateTime.Now.Month == 1) { if (DateTime.Now.Year == 2011) { if (DateTime.Now.Month == 1) { if (DateTime.Now.Year == 2011) { Console.WriteLine("It works"); } } } } } } } } } } } } } } Console.ReadKey(); }
source share