C#代码协定:如何检查关联性 [英] C# code contract: how to check associativity

查看:65
本文介绍了C#代码协定:如何检查关联性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将二进制操作的关联性编码为代码协定.

I'm trying to encode associativity of a binary operation as Code contract.

到目前为止,以下是我的空缺.这样做是什么明智的方法?

Below is my atempt so far. What would be a sensible way to do it ?

推荐答案

Kikipoi,

Hi Kikipoi,

谢谢您在这里发布.

对于您的问题,您可以参考MSDN文章

For your question, you could refer to the MSDN article Code Contracts.

在本文中,它很好地解释了

In the article, it has a good explanation of specify preconditions, postconditions, and object invariants in your code.

  • 前提条件是输入方法或属性时必须满足的要求.
  • 后置条件描述了方法或属性代码退出时的期望值.
  • 对象不变式描述处于良好状态的类的预期状态.
  • Preconditions are requirements that must be met when entering a method or property.
  • Postconditions describe expectations at the time the method or property code exits.
  • Object invariants describe the expected state for a class that is in a good state.


这篇关于C#代码协定:如何检查关联性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆