小编You*_*lty的帖子

寻找错误的命名空间?

我有一些名称空间问题令我困惑,为什么会发生这种情况.

在下面的代码中,System.IO和System.Reflection试图引用abc.System,而不是使用我在顶部声明的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);         }
}
Run Code Online (Sandbox Code Playgroud)

然后我在另一个文件中有另一个命名空间,如下所示:

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 …
Run Code Online (Sandbox Code Playgroud)

.net c#

1
推荐指数
1
解决办法
545
查看次数

标签 统计

.net ×1

c# ×1