How to remember to use return value?
<p>Sometimes I forget to use the return value when I <strong>have</strong> to. For example</p>

<pre><code>var s = "foobar";
s.Replace("foo", "notfoo");
// correct: s = s.Replace("foo", "notfoo");
</code></pre>

<p>This also applies to my custom value-like classes, for example, where I use fluent x.WithSomething() methods that return new value object instead of modifying x.</p>

<p>One solution would be to use unit tests. However, this is not always applicable. So, how do I force a compiler - or, at least, runtime - error when returned value is not used?</p>

<p>Maybe, there's a ReSharper or VS solution?</p>

<p>UPDATE: OK it is not enforced by language. So null arguments are, but still I can throw exception if argument is null. And ReSharper can warn me about many things that are not enforced by C#. But I see no way to do the same for not-used return value - for those return values that I want to be used.</p>

<p>If not for system functions (like string.Replace), but at least for my own classes - is there any way? Like, returning RequiredReturn&lt;T&gt; or something like this.</p>

<p>UPDATE: what about AOP / PostSharp? If I mark return value or method with [UsageRequired], can I detect somehow using PostSharp that return value was used?</p>

<p>(note the C# tag)</p>
