Beispiel #1
0
        public bool Create(Product product)
        {
            bool added = products.Add(product);

            serializer?.WriteProducts(products); //Null-conditional Operator
            return(added);
        }
        public bool Create(Product product)
        {
            //Set can't store duplicates. Need to override Equals and GetHashCode
            bool added = products.Add(product);

            if (serializer != null)
            {
                serializer.WriteProducts(products);
            }
            return(added);
        }