x++ - 可选参数可为空
问题描述
上下文:
在 Ax 中,我公开了一个 Web 服务。该方法采用 3 个参数。其中两个应该是Nullable<>
,但我在 X++ 中没有这样做。
在 c# 中,代码如下所示:
private static void FooBar(string[] things, DateTime? d1, DateTime? d2)
{
if (d1 == null || d2 == null)
{
//Do Something
}
else {
//Something Else
}
}
我怎么翻译这个?如何使用构建可选的可空参数构建方法?
X++不支持方法重载。
解决方案
这应该转化为以下内容:
private static void FooBar(str things[], utcdatetime d1 = DateTimeUtil::minValue(), utcdatetime d2 = DateTimeUtil::minValue())
{
if(d1!=DateTimeUtil::minValue()||d2!=DateTimeUtil::minValue())
{
//do something
}
else
{
//something else
}
}
things
是强制性的,d1
&d2
是可选的
推荐阅读
- python - 我应该如何处理两个项目共享的本地依赖项?
- javascript - TypeError:无法读取详细信息页面中未定义的属性“参数” - React / Express 中的基本 CRUD 应用程序
- html - 如何使输入框在容器内居中而不被标签向下推?
- reactjs - 重新渲染后创建精确数量的 ref
- view - 不能在本地范围内使用 'bgcolor' [Pinescript] [tradingview]
- c# - 使用 Razor 将由字符串列表组成的表格单元格“包装”到新表格行中
- reactjs - WYS 不是 React Quill 中的 WYG
- php - 如何在 Laravel 8 中验证数据、保护路由、授权路由/动作
- php - Elementor 插件中的弹窗干扰
- java - 如何将 logback-spring.xml 转换为 spring.properties