While I thought this was an exact duplicate of this question, it's actually different. The linked question assumes you have not already provided the fully-qualified class name. For instance, if you happen to have string fullPath = Path.Combine(path1, path2);
instead of string fullPath = System.IO.Path.Combine(path1, path2);
and without the using directive using System.IO;
at the top of the file -- maybe you inserted a code snippet or copy/pasted from somewhere else -- you can place your cursor near the class (Path
) and use Ctrl + . to activate the smart tag.
This is different from my question because I have already provided the fully-qualified class name System.IO.Path
(because maybe I couldn't have found Path
without it). I'd like it to recognize that there's a namespace component that can be converted into a using
directive and remove the namespace component from the beginning of Path
. If you do already have the namespace component before the class name, the Ctrl + . shortcut, does not work, and there is no explanation provided. The work-around is to type out the fully-qualified class name, then delete the namespace component, and use Ctrl + .. This allows you to make use of the intellisense for getting the class name you're looking for from whatever namespace it resides in, and then use the smart tag to add the using
directive.