none
Maximum number of if statement within a method RRS feed

  • Question

  • Hi

    May I know any limit of if statement within a method? for example as below..

    if (a==1) {return 1;}
    
    if (a==2) {return 2;}
    
    if (a==3) {return 3;}
    
    if (a==4) {return 4;}
    
    if (a==5) {return 5;}
    
    if (a==6) {return 6;}
    
    if (a==7) {return 7;}
    
    ....
    
    if (a==n) {return n;}
    

    If I have 26,000 if, w3wp.exe will crash. Any ideas?

    Thank you

    Thursday, July 24, 2014 6:12 AM

All replies

  • hello,

    There is no raison to crash when you have 26000 if statement in your code.

    I think, your exemple is not your current code but, why don't you use something like that ?

      for (int i = 0; i< 26000; i++)
                    if (a == i) { return i; }

    Did you have seen the callstack into a debugger to know why there is a crash ?

    Did you have seen the process memory ?

    regards

    Cédric

    Thursday, July 24, 2014 7:45 AM