나는 왜 그것이 일어나고 있는지 혼란스럽게하는 몇 가지 이름 공간 문제가 있습니다.틀린 네임 스페이스를 찾고 계십니까?
아래 코드에서 System.IO & System.Reflection은 위에서 선언 한 System 네임 스페이스 대신 abc.System을 참조하려고 시도하고 있습니다. 왜 그런가요?
using System;
using System.Collections.Generic;
using System.Data.OleDb;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc.Data
{
public sealed class Access
{
public static void Open(string dbPath)
{
// error here referencing abc.System in System.IO, and System.Reflection.
string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); }
}
다음과 같이 그때 별도의 파일에 다른 네임 스페이스를
:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc.System
{
public static class DateTimeExtensions
{
// Implemented from
// http://stackoverflow.com/questions/38039/how-can-i-get-the-datetime-for-the-start-of-the-week
public static DateTime StartOfWeek(this DateTime dt, DayOfWeek startOfWeek)
{
int diff = dt.DayOfWeek - startOfWeek;
if (diff < 0)
{
diff += 7;
}
return dt.AddDays(-1 * diff).Date;
}
public static DateTime EndOfWeek(this DateTime dt, DayOfWeek startOfWeek)
{
int diff = dt.DayOfWeek - startOfWeek;
if (diff < 0)
{
diff += 7;
}
return dt.AddDays(diff).Date;
}
}
}
"System.IO & System.Reflection이 abc를 참조하려고합니다"라는 것은 무엇을 의미합니까? –
대답 후, 나는 이것이 아마도 http://stackoverflow.com/questions/5681537/namespace-conflict-in-c-sharp의 복제임을 깨달았다. – Tim