【发布时间】:2014-01-18 16:38:17
【问题描述】:
我有一个名为 myResult 的数据表,它有两列 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 类的 Process 属性的 set 子句中抛出。
我在哪里做错了? 谢谢。
【问题讨论】:
-
你在开玩笑吗?你的代码明显抛出了这个异常
-
您到处都有
throw new NotImplementedException(),因此收到该错误应该不会让您感到惊讶。您是否尝试过在调试模式下运行代码? -
您的代码完全按照您的指示行事。你不明白什么?
-
您的代码完全按照您的指示行事。你不明白什么? - 很可能我想在这里学习!异常是在我实现接口时由 vs13 自动添加的。