Friday, August 08, 2008
I found this great article about switch statements in c# (really any CLS language.)  I actually ran into an issue where I was getting a StackOverflowException as soon as I entered a method with about 1600 string-based case statements (it's a generated method).  It looks like I was bumping my head the local variables limit in .Net 1.1.  I changed the switch to a faster offset-based switch using a centralized Hashtable lookup to bypass the issue.

Actually, I found the problem using Reflector and examining the MSIL first.  Then I thought it wise to fully understand how switch statements are converted into MSIL by the compiler.

posted on Friday, August 08, 2008 12:29:26 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
Related posts:
WTF
I can haz Clipboard
Time-out interval must be less than 2^32-2
Comments are closed.