次のスーパークラスがあります。
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.