null-coalescing-operator
Null coalescing within an invocation chain
If I have a long list of objects that each has the possibility of returning null within a \"Linq where\" clause, e.g.[详细]
2023-02-09 23:06 分类:问答Is there a cleaner way to set this anonymous class property?
I am开发者_StackOverflow中文版 returning an anonymous class: var clients = from c in this.ClientRepository.SearchClientByTerm(term, 10)[详细]
2023-01-23 23:49 分类:问答What is the result if all parameters in a null coalescing operation are null?
When this code finishes, what is t开发者_如何学编程he result of myObject? object myObject = \"something\";[详细]
2023-01-21 13:41 分类:问答Coalesce operator in C#?
I think i remember seeing something similar to the ?: ternary operator in C# that only had two parts to it and would return the variable value if it wasn\'t null and a default value if it was.Somethin[详细]
2023-01-20 10:26 分类:问答Using null coalescing in foreach statement
Trying to figure out how to get the null coalescing operator to work in a foreach loop. I\'m checking to see what a string ends with and based on that, route it to a certain method. Basically what I[详细]
2023-01-17 06:07 分类:问答Is there a more elegant way to add nullable ints?
I need to add numerous variables of type nullable int. I used the null coalescing operator to get it down to one variable per line, but I have a feeling there is a more concise way to do this, e.g. ca[详细]
2023-01-14 08:49 分类:问答Weird operator precedence with ?? (null coalescing operator)
Recently I had a weird bug where I was concatenating a string wi开发者_StackOverflow社区th an int? and then adding another string after that.[详细]
2023-01-08 00:56 分类:问答Is there an "opposite" to the null coalescing operator? (…in any language?)
null coalescing translates roughly to return x, unless it is null, in which case return y I often need return null if x is null, otherwise return x.y[详细]
2023-01-01 04:22 分类:问答Negate the null-coalescing operator
I have a bunch of strings I need to use .Trim() on, but they can be null.It would be much more concise if I could do something like:[详细]
2022-12-31 15:08 分类:问答how do I treat null lists like empty lists in linq?
Below is some linqpad test code. When this runs it errors because the second instance of \"item\" has a null list of subitems as opposed to an empty list.[详细]
2022-12-18 23:06 分类:问答