Quantcast
Channel: netfx Discussions Rss Feed
Viewing all articles
Browse latest Browse all 20

New Post: Guard and Removing the value parameter.

$
0
0

Why are both "expression" and "value" passed in as parameters, when you can derive the value from the expression?

example:

publicstaticvoid NotNull<T>(Expression<Func<T>> reference)
{
    T value = reference.Compile()();if (value == null)thrownew ArgumentNullException(GetParameterName(reference), "Parameter cannot be null.");
}

Is Compile so expensive you must also pass in the value separately?


Viewing all articles
Browse latest Browse all 20

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>