English 中文(简体)
有条件的声明
原标题:Conditional Statement Checking Null

我试图说明如何有简短、一行的有条件说明。

如果这一日期没有取消,则在现有过滤器清单中添加过滤器:

from Dt ? Add(FilterType.DateFrom, fromDt);

是否有办法这样做? 我知道我可以这样做。

http://www.un.org。 “有点”:“有点_else”,但我不需要其他东西,而且真的希望只是使用<代码>?

最佳回答

这有什么错误?

if (fromDt != null) filters.Add(FilterType.DateFrom, fromDt);

首先,你的法典应当读懂。 即便您的<代码>?的代码有效,我还是不知道在一线上做了些什么。

问题回答

Purpose of the solution aside, following one-liner might give you end result you want while using ??. Do not try this at home though.

<代码>过滤器。 Add(FilterType.DateFrom, from Dt ?) 日期:MinValue

设想是确定日期,使之达到可能的价值,基本上增加公开过滤器。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签