.Net 3.5 Implementation of String.IsNullOrWhitespace with Code Contracts
问题 I'm attempting to use Contracts in my .Net 3.5 (C#) project. I found where I had written something like if (string.IsNullOrEmpty(s) || string.IsNullOrEmpty(s.Trim())) throw new ArgumentException("Required", "s"); at the beginning of methods. I could keep them there and use legacy contracts. I could change it to Contract.Requires(s!= null && string.IsNullOrEmpty(s.Trim())); . But besides not being very sure about the correctness or performance of the Whitespace part of the condition, those are