0

对,我有一个用于仓库的程序。我正在尝试使用报表查看器来显示信息,以便用户可以打印它们。在其中一种形式中,用户可以决定查看多少项目(在 x 和 y 的日期之间)。

我现在面临的问题是 C# 给我一个错误:

internal void Fill(DataSetAllTheStock.DeliveryDataTable deliveryDataTable, string p, string p_2)
{
   throw new System.NotImplementedException();
}

错误是:

“NotImplementedException 未处理。方法或操作未实现。”

InnerException = null

你知道我能做什么吗?因为我需要使用记者视图,还需要用户选择日期。

4

1 回答 1

0

在上面的示例中,您只是抛出错误而不是捕获它。你应该这样做:

internal void Fill(DataSetAllTheStock.DeliveryDataTable deliveryDataTable, string p, string p_2)
{
   try
   {
      // Do some things here.
   }

   catch (NotImplementedException exc)
   {
      // Handle the exception here.
   }

   catch (Exception exc)
   {
      // Or, handle the exception here.
   }
}

在上面的示例中,请注意我捕获了两种类型的异常:1)最普遍的“异常”类型和 2)更具体的“NotImplementedException”类型。C# 中的异常处理从最具体的类型到最通用的类​​型。此外,阅读异常处理似乎对您有所帮助。

于 2013-11-05T21:08:44.510 回答