Coffeehouse Post

Single Post Permalink

View Thread: Select Case behavior
  • User profile image
    Maddus Mattus

    I've seen Bart Desmet showing what switch case statements are like when you compile them to IL,. It's really funny!

    When you do;

    int i = 0;
    switch(i)
    {
    case 8:
    bla();
    break;
    case 9:
    bla9();
    break;
    }

    it actually compiles into;

    int i = 8;
    switch(i)
    {
    case 0:
    bla();
    break;
    case 1:
    bla9();
    break;
    }

    They also do all sorts optimizations for multiple ranges,.. Was really fun session!

    here it is; http://channel9.msdn.com/Events/DevDays/DevDays-2011-Netherlands/Devdays041

    man I love C9