c# - Give "this" as default value of class method -
this question has answer here:
i want use this
default value of class method code:
public class article { public int id;//pk public string author;//can empty=anonymous public int? topublishdate; public string summery; public string content; public int regdate; public boolean publish; private boolean write(article article=this,long position) { return true; } }
but on this
give me error:
default parameter value 'article' must compile-time constant.
why error occurs , how can fix it?
you set default null, , reset default in method:
private boolean write(long position, article article=null) { article = article ?? this; }
(note non-default parameters have come before default ones.)
Comments
Post a Comment