This feature is very helpful to use in a scenario like to get the property value from the object only if object is not null.
As per the above code in C# 6.0, action is not null and Method is not null then only "Name" property value is assigned otherwise "Empty" value will be assigned.
For
Example, you are considering delegate Action as the parameter to any of
the method, You want to get the name from the Action Method only if
Action is not null and Action.Method is not null.
You can easily get an idea by just looking the below code.
public void LogAction(Action action) { //Before C# 6.0 var actionName = "Empty"; if (action != null && action.Method != null) { actionName = action.Method.Name; } //C# 6.0 var actionName = action?.Method?.Name ?? "Empty"; }
As per the above code in C# 6.0, action is not null and Method is not null then only "Name" property value is assigned otherwise "Empty" value will be assigned.
Hi,
ReplyDeleteI have read your angularjs blog.It"s very attractive and impressive.Very useful to me, I like it your blog
Thanks for sharing this blog.......
Thank you
priya
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeleteAngularJs Training In Electronic city
Python Training In Electronic city
DataScience Training In Electronic city
AWS Training In Electronic city
Big Data Hadoop Training In Electronic city
Devops Training In Electronic city
Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.We are providing AngularJs training in velachery.
ReplyDeleteFor more details: AngularJs training in velachery
Expected to form you a next to no word to thank you once more with respect to the decent recommendations you've contributed here. Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition. We are providing AngularJs training in velachry.
ReplyDeleteFor more details: AngularJs training in velachery