I have a class like this:
public class Article {
private Category? category;
private string content;
public Article(Category? category,string content){
Contract.Ensures(this.category == category); // error
}
}
but on Ensure
method this error occurs:
Operator '==' cannot be applied to operands of type 'Category?' and 'Category?'
How can I avoid that?
You'll need to overload the
==
operator for that type if you expect to be able to use it to compare two instances (whether nullable or not) of that type.