S_pot
210518 C#_namespace 본문
using static System.Console;
namespace Second
{
class Smart
{
}
}
namespace First
{
class Smart
{
static void Main(string[] args)
{
First.Smart aSmart1 = new First.Smart();
First.Smart aSmart2 = new First.Smart();
Second.Smart aSmart3 = new Second.Smart();
aSmart1 = aSmart2;
//aSmart1 = aSmart3; // namespace가 같지않아 적용할 수 없다.(다른클래스이므로 대입불가)
// namespace를 분리함으로써 이름이 충돌하는 것을 사전에 방지할 수 있다.
WriteLine("지옥으로 키티");
}
}
}
'C#' 카테고리의 다른 글
210518 C#_Nullable (0) | 2021.05.18 |
---|---|
210518 C#_상수 (0) | 2021.05.18 |
210518 C#_소수 구하기 (0) | 2021.05.18 |
210517 C#_class, 객체생성 (0) | 2021.05.17 |
210517 C#_ref(래퍼런스) (0) | 2021.05.17 |