<p>Is there a one statement or one line way to accomplish something like this, where the string s is declared AND assigned the first non-null value in the expression?</p>

<pre><code>//pseudo-codeish
string s = Coalesce(string1, string2, string3);
</code></pre>

<p>or, more generally,</p>

<pre><code>object obj = Coalesce(obj1, obj2, obj3, ...objx);
</code></pre>

[{'answer_id': 42387, 'author': 'Darren Kopp', 'author_id': 77, 'author_profile': 'https://Stackoverflow.com/users/77', 'pm_score': 2, 'selected': False, 'text': '<p>the <strong>??</strong> operator.</p>\n\n<pre><code>string a = nullstring ?? "empty!";\n</code></pre>\n'}, {'answer_id': 42397, 'author': 'Erik van Brakel', 'author_id': 909, 'author_profile': 'https://Stackoverflow.com/users/909', 'pm_score': 4, 'selected': False, 'text': '<p>As Darren Kopp said.</p>\n\n<p>Your statement</p>\n\n<pre><code>object obj = Coalesce(obj1, obj2, obj3, ...objx);\n</code></pre>\n\n<p>Can be written like this:</p>\n\n<pre><code>object obj = obj1 ?? obj2 ?? obj3 ?? ... objx;\n</code></pre>\n\n<p>to put it in other words:</p>\n\n<pre><code>var a = b ?? c;\n</code></pre>\n\n<p>is equivalent to</p>\n\n<pre><code>var a = b != null ? b : c;\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/42386', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4438/']