is it possible to have a conditional field in an anonymous type

后端 未结 1 1097
悲哀的现实
悲哀的现实 2021-01-11 18:45

i have some code that looks like this and creates a list from an existing collection

 var items = items.ConvertAll(r => new
            {
                         


        
相关标签:
1条回答
  • 2021-01-11 19:24

    No, you can't, mostly since it would make the anonymous class different in different executions and the class couldn't be type checked.

    I'd recommend setting your Start date to null instead of a default, and checking for that later in your code.

    0 讨论(0)
提交回复
热议问题