Although in this case, you can simply get rid of the variable "x" (as mentioned by Mark). Typically, for scenarios where I have these warnings and cannot change the code (for example, using some fields by reflection), I usually prefer not to do anything to call the conditional compilation method, which suppresses such annoying warnings.
The code is below.
catch (ChangeConflictException x) { DoNothingWith(x);// This suppress the 'x' not used warning foreach (ObjectChangeConflict occ in DB.ChangeConflicts) { occ.Resolve(RefreshMode.KeepChanges); } } [Conditional("Debug")] public static void DoNothingWith(object obj){ }
MSDN link for conditional attribute: "Conditional method calls are enabled or dropped depending on whether this character is defined at the dial peer. If the character is defined, the call is on, otherwise the call (including the evaluation of the call parameters) is omitted."
Manish basantani
source share