using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Chap2_3
{
class Program
{
static void Main(string[] args)
{
ProductCollection products=new ProductCollection();
#region 没有判断,直接迭代
//products.Products.ForEach(product =>
// {
// product.CompanyNodes.ForEach(node =>
// {
// //TODO
// }
// );
// });
#endregion
#region 有判断
//if (products.Products == null || products.Products.Count == 0)
// return;
//products.Products.ForEach(product =>
// {
// if (product == null || product.CompanyNodes == null || product.CompanyNodes.Count == 0)
// return;
// product.CompanyNodes.ForEach(node =>
// {
// //TODO
// });
// });
#endregion
}
}
public class ProductCollection
{
public List<Product> Products { get; set; }
}
public class Product
{
public string PName;
public List<string> CompanyNodes{get;set;}
}
}