Why doesn’t C# warn about unused methods?

Q: Why doesn’t C# warn on unused methods?

A: This is something that the C# compiler could do, subject to a few caveats:

  • Virtual functions would have to be excluded
  • Interface implementations wouldn have to be excluded
  • You would get false positives if you used reflection
  • You might get false positives if you used delegates (the compiler might be able to be smart here)

Other than that, it would be possible for us to do this, and we may do it in a future version.



[Author: Eric Gunnerson]