I have this simple code:
public ArrayStack(int capacity)
{
Contract.Requires(capacity >= 0);
Contract.Ensures(_items != null);
Contract.Ensures(_items.Length == capacity);
_items = new T[capacity];
_top = -1;
}
I expected that once I type the followig I will get a compile time warning, but I only get a runtime exception from the contract.
static void Main(string[] args)
{
int i = -1;
ArrayStack<string> stack = new ArrayStack<string>(i);
}
any ideas?
EDITED: picture of my code contract settings