public Store.Product FindProduct(string barcode) { bool found = false; // Check if the item exists string fileContents = ReadFile(); string[] c = { "\r", "\n" }; string[] products = fileContents.Split(c, StringSplitOptions.RemoveEmptyEntries); char[] delimiter = { ',' }; foreach (string s in products) { string[] temp = s.Split(delimiter); Store.Product product = new Store.Product() { Barcode = temp[0], Brand = temp[1], Description = temp[2], Price = Decimal.Parse(temp[3]) }; if (product.Barcode.Equals(barcode)) { found = true; return(product); } } return(null); }
public Store.Product FindProduct(string barcode) { bool found = false; // Check if the item exists string fileContents = ReadFile(); string[] c = {"\r", "\n"}; string[] products = fileContents.Split(c, StringSplitOptions.RemoveEmptyEntries); char[] delimiter = {','}; foreach (string s in products) { string[] temp = s.Split(delimiter); Store.Product product = new Store.Product() { Barcode = temp[0], Brand = temp[1], Description = temp[2], Price = Decimal.Parse(temp[3]) }; if(product.Barcode.Equals(barcode)) { found = true; return product; } } return null; }