Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding unused enum members

Tags:

c#

enums

What is the quickest way to determine which members of an enum are not being used?

like image 256
JC. Avatar asked Sep 02 '25 03:09

JC.


2 Answers

Comment the enum members out one by one and see if your code compiles. If compilation breaks, the member is used. Although this method only catches compile-time use of your enums. They could be used at runtime.

like image 94
LeonZandman Avatar answered Sep 05 '25 01:09

LeonZandman


If you're using ReSharper, click on the enum to check, hit Alt+F7 (Shift+F12 if you're using VS shortcuts), and it'll give you a list of every place it's used in your entire solution.

like image 27
Chris Doggett Avatar answered Sep 05 '25 01:09

Chris Doggett