missing return statement in factory pattern c# -
i have following code code says return statement missing, though have put them in switch list.
public imap map(string oldtheme) { switch (oldtheme) { case "archer": return new archer(); case "craftyblue": return new craftyblue(); case "minimal": return new minimal(); case "mintalicious": return new mintalicious(); case "misfit": return new misfit(); case "peach": return new peach(); case "queen": return new queen(); case "sketch": return new sketch(); case "takeaway": return new takeawaylemonfresh(); case "lemonfresh": return new takeawaylemonfresh(); case "vanilla": return new vanilla(); case "velvet": return new velvet(); case "victoriana": return new victoriana(); case "writer": return new writer(); } }
you need handle case when oldtheme
none of values check for.
depending on case, suggest throwing argumentexception
know when happens. have added default
case switch
statement:
public imap map(string oldtheme) { switch ( oldtheme ) { case "archer": return new archer(); case "craftyblue": return new craftyblue(); case "minimal": return new minimal(); case "mintalicious": return new mintalicious(); case "misfit": return new misfit(); case "peach": return new peach(); case "queen": return new queen(); case "sketch": return new sketch(); case "takeaway": return new takeawaylemonfresh(); case "lemonfresh": return new takeawaylemonfresh(); case "vanilla": return new vanilla(); case "velvet": return new velvet(); case "victoriana": return new victoriana(); case "writer": return new writer(); default: throw new argumentexception("unexpected value of oldtheme"); } }
Comments
Post a Comment