不使用命名空间并使用带有命名空间的类有什么好处吗? [重复]

问题描述 投票:0回答:1

我的意思是不去

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

也可以做到

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

除了可读性之外,这两种选择还有什么好处吗?

c# namespaces using
1个回答
1
投票

它被编译成同样的东西,但是:

  1. 代码更易读
  2. 更少的代码输入
  3. 开发者可以快速的看到class文件中使用了哪些usings
© www.soinside.com 2019 - 2024. All rights reserved.