Take the 2-minute tour ×
string myString = string.Format("{0}{1}", "foo");

This compiles but fails at runtime. I know why, don't worry. Anyone knows of a macro or a tool that would check my whole solution to find every occurrence of this... distraction while coding? Something simple that only checks if the expression is not a variable would suffice. It's probably doable with FxCop or StyleCop, but the simpler the better :-D


share|improve this question
You write unit tests to flush out bugs like these. And many more. –  Hans Passant Aug 17 '11 at 21:16

2 Answers 2

up vote 5 down vote accepted

Try resharper from jetbrains .. enter image description here

share|improve this answer
In the past, I tried ReSharper, but not for too long since I was just beginning coding. Today, I reinstalled the trial and I really liked it! Thanks for this suggestion! –  Tipx Aug 19 '11 at 3:45

I use Visual Studio 2010 (Premium) and (menu) Analyze > Run Code analysis does the trick (and many many others). I don't know if this works in other VS versions.

share|improve this answer
Home, I got a VS version I bought cheap when I was in university so it has that feature, but sadly, I can't use VS2010 yet at my workplace, they haven't upgraded yet. I like this answer though since it's so simple, yet working! –  Tipx Aug 19 '11 at 3:47

Your Answer


