CodeContracts: How to fullfill Require in Ctor using this() call?
- by mafutrct
I'm playing around with Microsoft's CodeContracts and encountered a problem I was unable to solve. I've got a class with two constructors:
public Foo (public float f) {
Contracts.Require(f > 0);
}
public Foo (int i)
: this ((float)i)
{}
The example is simplified. I don't know how to check the second constructor's f for being 0. Is this even possible with Contracts?