I was looking at some code with a huge switch statement and an if-else statement on each case and instantly felt the urge to optimize. As a good developer always should do I
I don't have VS to hand but surely there's a simple built-in way to get the key as a character? Something like a toString
method so you can replace that monstrous switch
with this:
if (shift)
return inKey.toString().toUppercase();
else
return inKey.toString().toLowercase();
I would choose the third option only because it is more readable/maintainable. I bet this code isn't the bottleneck of your application performance.