gpt4 book ai didi

c# - 抛出异常应该是第一件事吗?

转载 作者:行者123 更新时间:2023-11-30 13:47:17 25 4
gpt4 key购买 nike

<分区>

什么是验证用户输入的正确方法(如果有的话......)

这个(先抛异常):

private void DisposeWorkFlowItem(WorkFlowItem item)
{
if (item == null)
{
throw new ArgumentException("work flow item must have value");
}
//TO DO: add a call to delete the task from worker service.
_workFlowItems.Remove(item);
_workFlowItemsStore.Delete(item);
}

或者这个(先做 Action ):

private void DisposeWorkFlowItem(WorkFlowItem item)
{
if (item != null)
{
//TO DO: add a call to delete the task from worker service.
_workFlowItems.Remove(item);
_workFlowItemsStore.Delete(item);
}
else
{
throw new ArgumentException("work flow item must have value");
}
}

有什么指导方针吗?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com