I want to use this
as default value of class method as this code:
public class Article
{
public int Id;//PK
public String Author;//can be 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 this error:
Default parameter value for 'article' must be compile-time constant.
Why this error occurs and how can I fix it?
You could set the default to null, and then reset its default in the method:
private Boolean write(long position, Article article=null)
{
article = article ?? this;
}
(Note also that all non-default parameters have to come before any default ones.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With