Is there any way to fix "using" in my C# file? I looking for some sort of "fix (organize) imports" from NetBeans or Eclise for java. I looking for the easiest way to fix issue: "The type or namespace could not be found" when I miss some "using" directive. Actually, I do not remember all C# classes hierarchy.
When you type the name of a type which isn't already imported, it will be highlighted in red. If you press Ctrl-period, Visual Studio will offer to import it. (There should be a blue dot near the cursor to indicate this as a possibility.) Or using ReSharper, press Alt-Enter on the line with the problem.
Note that that only tackles the "adding a using directive" side of things. There's also the "Remove and sort using directives" command for keeping things tidy. I typically having that bound to Ctrl-Shift-U, but I don't think it has a shortcut by default.
If you have the necessary assemblies referenced, you can right click (or hover) on an unrecognized class name to find a "Resolve" submenu to help you. You can find options to add necessary usings or change the class name to fully qualified with namespaces in your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With