阅读背景:

代码合同:为什么有些不变量不在课堂之外考虑?

来源:互联网 

Consider this immutable type:

考虑这种不可变类型:

public class Settings
{
    public string Path { get; private set; }

    [ContractInvariantMethod]
    private void ObjectInvariants()
    {
        Contract.Invariant(Path != null);
    }

    public Settings(string path)
    {
        Contract.Requires(path != null);
        Path = path;
    }
}
pu



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: