System.DateTime? vs System.DateTime

后端 未结 6 1071
心在旅途
心在旅途 2021-02-05 02:53

I was writing to some code where I needed to read the date value from a Calendar control in my page (Ajax toolkit: calendar extender).

The code below:

6条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-05 03:27

    You can use the ?? operator to work with nullables in a very concise way in C#. See my comment on Travis's answer for a shorter way of expressing the "if not null then use it else use some default value" concept. They both do the same thing.

提交回复
热议问题