How useful is C#'s ?? operator?

后端 未结 13 2139
独厮守ぢ
独厮守ぢ 2020-12-08 07:43

So I have been intrigued by the ?? operator, but have still been unable to use it. I usually think about it when I am doing something like:

var x = (someObje         


        
13条回答
  •  鱼传尺愫
    2020-12-08 08:04

    I've been using it with App.Config stuff

    string somethingsweet = ConfigurationManager.AppSettings["somesetting"] ?? "sugar";
    

提交回复
热议问题