inherit方法抛出错误

本文关键字:错误 出错 方法 inherit | 更新日期: 2023-09-27 18:23:39

我有以下超类:

   abstract class ContactQueue
{
    public abstract DateTime period { 
        get; set; }
    public abstract String type { get; set; }
    public abstract String toString();
    public String ReWritePeriod(String choice) 
    {
        new CultureInfo("da-DA");
        switch (choice)
        {
            case ("Day"):
                return period.ToString("ddd");
            case ("Week"):
                return ""+period.ToString("ddd")+" Uge: "+weekNumber(period);
            case ("Year"):
                return period.Year.ToString();
            default:
                return "";
        }
    }
    private int weekNumber(DateTime fromDate)
    {
        // Get jan 1st of the year
        DateTime startOfYear = fromDate.AddDays(-fromDate.Day + 1).AddMonths(-fromDate.Month + 1);
        // Get dec 31st of the year
        DateTime endOfYear = startOfYear.AddYears(1).AddDays(-1);
        // ISO 8601 weeks start with Monday 
        // The first week of a year includes the first Thursday 
        // DayOfWeek returns 0 for sunday up to 6 for saterday
        int[] iso8601Correction = { 6, 7, 8, 9, 10, 4, 5 };
        int nds = fromDate.Subtract(startOfYear).Days + iso8601Correction[(int)startOfYear.DayOfWeek];
        int wk = nds / 7;
        switch (wk)
        {
            case 0:
                // Return weeknumber of dec 31st of the previous year
                return weekNumber(startOfYear.AddDays(-1));
            case 53:
                // If dec 31st falls before thursday it is week 01 of next year
                if (endOfYear.DayOfWeek < DayOfWeek.Thursday)
                    return 1;
                else
                    return wk;
            default: return wk;
        }
    }
}

我有下面的类继承了上面的类:

class Callback : ContactQueue
{
    public int completedCallbacks{get; set;}
    public int completed_within_timeframe{get; set;}
    public int answerPercentage { get; set; }
    public override String type {get; set;}
    public override DateTime period { get; set; }
    public Callback(String type,DateTime period)
    {
        this.type = type;
        this.period = period;
    }
    public override String toString()
    {
        return type;
    }
}

现在我想测试我的继承方法是否真的有效,所以我做了以下操作:

        Callback cb = new Callback("Callback",start);
        MessageBox.Show(cb.ReWritePeriod("Day"));

在这一点上,我的程序抛出了一个错误!

我做错了什么?

错误消息

The invocation of the constructor on type 'Henvendelser.MainWindow' that matches the specified binding constraints threw an exception.

inherit方法抛出错误

错误(以及异常原因)似乎在行

  new CultureInfo("da-DA");

没有"da"这样的文化。你的意思是"de de"(德国)还是"da DK"(丹麦)?

相关文章: