Search code examples
c#namespacesusing

Is there any benefit to not using a namespace and using the class with the namespace instead?


What I mean is instead of going

using System.Text.RegularExpressions;
[...]
Regex.IsMatch(string, pattern, RegexOptions.IgnoreCase);

it's also possible to do

System.Text.RegularExpressions.Regex.IsMatch(string, pattern, RegexOptions.IgnoreCase);

Is there any benefit to either option besides readability?


Solution

  • It gets compiled into the same thing, but:

    1. Code is easier to read
    2. Less code to type
    3. Developer can quickly see what usings are used in class file