I got an error today while trying to do some formatting to existing code. Originally, the code had the using
directives declared outside the namespace:
using System.Collections.Generic;
namespace MyNamespace
{
using IntPair = KeyValuePair<int, int>;
}
When I tried to insert the using
directive inside the statement (to comply with StyleCop's rules), I got an error at the aliasing directive, and I had to fully qualify it:
namespace MyNamespace
{
using System.Collections.Generic;
//using IntPair = KeyValuePair<int, int>; // Error!
using IntPair = System.Collections.Generic.KeyValuePair<int, int>; // works
}
I wonder what difference there is between the two cases? Does the location of the (import-style) using
directive matter?