我有 WCF 服务,我正在处理客户对象,并基于此我需要发送与客户相关的产品数组。
所以我的问题是,如果没有针对特定客户的没有产品 我应该将 Null 值还是空的 Products 数组返回给 WCF 客户端?
请告知执行此操作的最佳方法。
[OperationContract]
Product[] DoProcess(Customer customer);
if(Product not found by Customer)
{
// return null;
// or
// return new Product[];
}
非常感谢。
请您参考如下方法:
最好是 return new Product[] 这样在客户端就不需要检查 null 的条件了。
