包被用来组织文件或公共类型以避免类型冲突。包结构可以映射到文件系统。

System.Security.Cryptography.AsymmetricAlgorithm aa;

可能被替换:

import System.Security.Crypography; 
class xxx { ...
AsymmetricAlgorithm aa;

软件包没有别名。你必须使用导入语句或完全限定名称来提及特定的类型。

package N1.N2;
    class A {}
    class B {}

要么

package N1.N2;
   class A {}

另一个源文件:

package N1.N2;
   class B {}

包不能嵌套。一个源文件只能有一个包语句。

C#

命名空间被用来组织程序,既作为一个程序的“内部”组织系统,也作为一个“外部”组织系统。

System.Security.Cryptography.AsymmetricAlgorithm aa;

可能被替换:

using System.Security.Crypography; 
AsymmetricAlgorithm aa;

或者,可以指定命名空间的别名,例如

using myAlias = System.Security.Crypography; 

然后参考该类

myAlias.AsymmetricAlgorithm 

namespace N1.N2
{
    class A {}
    class B {}
}

要么

namespace N1
{
    namespace N2
    {
        class A {}
        class B {}
    }
}

from: https://cloud.tencent.com/developer/ask/35308
http://www.javacamp.org/javavscsharp/namespace.html

相关文章:

  • 2021-11-14
  • 2021-10-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-29
  • 2021-08-04
  • 2021-12-23
  • 2022-12-23
  • 2021-09-29
  • 2021-07-17
相关资源
相似解决方案