Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何实现输入参数排序的前置条件执行?
一些代码将帮助我们所有人帮助您。
我会假设你有一个沿着这条线的方法..
public void MyMethod(params string[] list) {...}
并且您想使用代码契约来确保只会使用排序列表调用此方法。您是否为身体尝试过以下类似的方法?
Contract.Requires(list.OrderBy(s => s).SequenceEquals(list));