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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -