C# 实现c接口

C# 实现c接口,c#,interface,datatable,C#,Interface,Datatable,我有一个名为myResult的dataTable,它有两列Process和ParentProcess,我正试图将其转换为Ienumerable类型,以便可以用Json.net序列化它 到目前为止,我有一个界面: namespace myFirstCProgramIn2013 { public interface Interface1 : IEnumerable { string Process { get; set; }

我有一个名为myResult的dataTable,它有两列Process和ParentProcess,我正试图将其转换为Ienumerable类型,以便可以用Json.net序列化它

到目前为止,我有一个界面:

namespace myFirstCProgramIn2013
    {
        public interface Interface1 : IEnumerable
        {
            string Process { get; set; }
            string ParentProcess { get; set; }
        }
    }
我已经在这个类中实现了它:

public class myArray : Interface1
{

    public string Process
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public string ParentProcess
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }

    public System.Collections.IEnumerator GetEnumerator()
    {
        throw new NotImplementedException();
    }
}
然后,我尝试使用该类使用以下代码将myResult分配给它:

   List<Interface1> recordList = new List<Interface1>();
   if (myResult.Rows.Count > 0)
   {
       foreach (DataRow row in myResult.Rows)
       {
           var myArray = new myArray();
           myArray.Process = Convert.ToString(row["Process"]);
           myArray.ParentProcess = Convert.ToString(row["ParentProcess"]);

       }
   }
我得到这个错误:

中发生“System.NotImplementedException”类型的异常 App_Web_hi4zxnmq.dll,但未在用户代码中处理

在myArray类的进程属性的set子句中抛出

这件事我哪里做错了?
谢谢。

您正在属性的setter上抛出NotInprementedException。如果要自动替换属性

    get
    {
        throw new NotImplementedException();
    }
    set
    {
        throw new NotImplementedException();
    }


你在开玩笑吗?您的代码很明显地抛出了这个异常您已经到处抛出了新的NotImplementedException,所以得到这个错误应该不会让您感到惊讶。您是否尝试过在调试模式下运行代码?您的代码正按照您的要求执行。你还不明白什么?你的代码完全按照你说的去做。你还不明白什么很多可能是我在这里想学的!当我实现接口时,异常是由vs13自动添加的。谢谢-因为异常是自动添加的,所以我认为它们是正确的。
    get; set;