how do i get index of an object in a custom class?
<p>I'm trying to an indexof method for a class that represents a list of objects.I would like to know the best approach. below is the code that I've come up with.</p>

<pre><code>public int IndexOf(Product product)
    {

            Product p;
            for (int i = 0; i &lt; products.Count; i++)
            {
                p = products[i];

                if (p == product)
                    return i;
            }
        return -1;
    }
</code></pre>
