Safe Navigation Operator in C#?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/3817930/shortcut-for-null-if-object-is-null-or-object-member-if-object-is-not-null">Shortcut for &ldquo;null if object is null, or object.member if object is not null&rdquo;</a>  </p>
</blockquote>



<p>Some languages have a safe navigation operator that lets you not worry about null reference exceptions.</p>

<p>Example of the language <a href="http://groovy.codehaus.org/" rel="nofollow">Groovy</a>:</p>

<pre><code>String lname = person.Name.ToLowerCase(); //throws exception if Name is null
String lname = person.Name?.ToLowerCase();//lname will be null if Name was null
</code></pre>

<p>How can I accomplish something similar to this in C#?  My solution so far is an extension method like this:</p>

<pre><code>public static T o&lt;T&gt;(this T obj) where T : new()
{
            return obj != null ? obj : new T();
}
//used like: String lname = person.o().Name; //returns null if person was null
</code></pre>

<p>However, this only works in some cases.</p>
