Skip to content

Variable declared but never used (CS0168)

Key dotnet.codequality.unused-variable · Severity warning · Category codequality

C# compiler warning CS0168. Flags a local variable - often a catch variable - that is declared and never used.

try
{
Save();
}
catch (DbUpdateException ex)
{
return Conflict();
}
try
{
Save();
}
catch (DbUpdateException)
{
return Conflict();
}