c# - inherit method throws error -
i have following super class:
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) { // jan 1st of year datetime startofyear = fromdate.adddays(-fromdate.day + 1).addmonths(-fromdate.month + 1); // dec 31st of year datetime endofyear = startofyear.addyears(1).adddays(-1); // iso 8601 weeks start monday // first week of year includes first thursday // dayofweek returns 0 sunday 6 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 previous year return weeknumber(startofyear.adddays(-1)); case 53: // if dec 31st falls before thursday week 01 of next year if (endofyear.dayofweek < dayofweek.thursday) return 1; else return wk; default: return wk; } } }
and have following class inheriting above class:
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; } }
now wanted test if inherit method worked did following:
callback cb = new callback("callback",start); messagebox.show(cb.rewriteperiod("day"));
and @ point program throws error!
what doing wrong?
error message
the invocation of constructor on type 'henvendelser.mainwindow' matches specified binding constraints threw exception.
it seems error (and exception's cause) in line
new cultureinfo("da-da");
there's no such culture "da-da". mean "de-de" (germany) or "da-dk" (denmark)?
Comments
Post a Comment