Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

null-conditional operators c#

// Prior to C# 6
var title = null;
if (post != null)
    title = post.Title;
// c#6
var title = post?.Title;

// Prior to C# 6
var count = 0;

if (post != null)
{
    if (posts.Tags != null)
    {
        count = post.Tags.Count; 
    }
}
 
// C# 6
var count = post?.Tags?.Count;
Source by www.informit.com #
 
PREVIOUS NEXT
Tagged: #operators
ADD COMMENT
Topic
Name
3+3 =