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);
}
}
[클래스 이름을 네임 스페이스와 동일하게 지정하지 마십시오.] (http://blogs.msdn.com/b/ericlippert/ archive/2010/03/09/do-not-name-a-class-same-as-its-namespace-part-one.aspx) – asawyer
Hasher 클래스는 공개되어 있습니까? GenerateFromRawData 정적입니까? 당신은 그것을 정적 메서드라고 부릅니다. 네, 네임 스페이스는 클래스 네임과 달라야합니다. – MBen
네임 스페이스의 적절한 이름은 "Hashing"입니다. –