我在名为 Hasher 的命名空间中有一个名为 Hasher 的类。因此,完全限定名称将是:
Hasher.Hasher ...
我正在尝试在外部程序集(C#)中使用 Hasher 类。我已将命名空间导入到我的类中:
using Hasher;
但是当我尝试使用 Hasher 类时,编译器将找不到它。
using Hasher;
namespace Test {
///<summary>
///This is a test class for HasherTest and is intended
///to contain all HasherTest Unit Tests
///</summary>
[TestClass()]
public class HasherTest {
///<summary>
///A test for GenerateFromRawData with null seed
///</summary>
[TestMethod()]
[ExpectedException( typeof( ArgumentNullException ) )]
public void GenerateFromRawDataTest_NullSeed() {
byte[] seed = null;
byte[] salt = null;
seed = null;
salt = null;
Hasher.GenerateFromRawData( seed, salt );
}
}
生成:
Error The type or namespace name 'GenerateFromRawData' does not exist in the namespace 'Hasher' (are you missing an assembly reference?) M:\j41833b_UR403088_ReportingDotNet\ReportingDotNet\src\AG385\_UnitTest\HasherTest.cs _UnitTest
我没有正确使用“使用”吗?(我的主要语言是 VB.NET,所以我的 C# 有点生疏。粗略检查 MSDN 文档并没有发现任何东西)
编辑:这很好用。
namespace Test {
///<summary>
///This is a test class for HasherTest and is intended
///to contain all HasherTest Unit Tests
///</summary>
[TestClass()]
public class HasherTest {
///<summary>
///A test for GenerateFromRawData with null seed
///</summary>
[TestMethod()]
[ExpectedException( typeof( ArgumentNullException ) )]
public void GenerateFromRawDataTest_NullSeed() {
byte[] seed = null;
byte[] salt = null;
seed = null;
salt = null;
Hasher.Hasher.GenerateFromRawData( seed, salt );
}
}