using System.Collections.Generic;
public Product(string name, double price)
public string Name { get; set; }
public double Price { get; set; }
public static class Utilities {
public static int IndexOf<T>(IEnumerable<T> source, Predicate<T> predicate)
throw new ArgumentNullException(nameof(source));
throw new ArgumentNullException(nameof(predicate));
foreach (T item in source) {
public static void Main()
var products = new Product[]
new Product("Product 1", 10.0d),
new Product("Product 2", 20.0d),
new Product("Product 3", 30.0d),
var productToFind = new Product("Product 3", 30.0d);
int index = Utilities.IndexOf(products, product => product.Name == productToFind.Name &&
product.Price == productToFind.Price);
Console.WriteLine(index);