Visual Studio 2010 - fix "use" function?

Is there a way to fix the “use” in my C # file? I am looking for something like "fix (arrange) import" from NetBeans or Eclise for java. I am looking for the easiest way to fix the problem: “Type or namespace could not be found” when I missed some “using” directive. In fact, I do not remember all the hierarchies of C # classes.

+4
source share
2 answers

When you enter a name for a type that has not yet been imported, it will be highlighted in red. If you press Ctrl-period, Visual Studio will prompt you to import it. (There should be a blue dot next to the cursor, indicating this as an opportunity.) Or using ReSharper, press Alt-Enter on the line with the problem.

Please note that this only applies to “adding a usage directive”. There is also a “Delete and Sort Using Directives” command to maintain order. I usually snap to Ctrl-Shift-U, but by default I don't think it has a shortcut.

+9
source

If you have the necessary assemblies, you can right-click (or hover) on the unrecognized class name to find the "Resolve" submenu to help you. You can find options for adding the required data or change the class name to fully match the namespaces in your code.

+4
source

Source: https://habr.com/ru/post/1341262/


All Articles