Random List of Products getting overwritten
<p>I'm trying to generate a random Product list using the following method, but I'm getting the same Product instance multiple times.</p>

<pre><code>Output for count 5:
Name: Qmlcloboa Price: 3.608848
Name: Qmlcloboa Price: 3.608848
Name: Qmlcloboa Price: 3.608848
Name: Qmlcloboa Price: 3.608848
Name: Qmlcloboa Price: 3.608848
</code></pre>

<p>I read on List type being a reference type &amp; it overwrites stuff. Below is my code. am I missing something which could give me unique Product instances? Thanks &amp; I would appreciate your help.</p>

<pre><code>public List&lt;Product&gt; ProductGroupGenerator(int count)
    {
        List&lt;Product&gt; pList = new List&lt;Product&gt;();

        for (int i = 0; i &lt; count; i++)
        {
            Random r = new Random();
            string alphabet = "abcdefghijklmnopqrstuvwyxzeeeiouea";
            Func&lt;char&gt; randomLetter = () =&gt; alphabet[r.Next(alphabet.Length)];
            Func&lt;int, string&gt; makeName =
              (length) =&gt; new string(Enumerable.Range(0, length)
                 .Select(x =&gt; x == 0 ? char.ToUpper(randomLetter()) : randomLetter())
                 .ToArray());

            //string last = makeName(r.Next(7) + 7);
            //string company = makeName(r.Next(7) + 7) + " Inc.";

            string prodName = makeName(r.Next(5) + 5);
            int unitsInStock = r.Next(100);
            float unitPrice = (float)(r.NextDouble() * 10);

            Product p = new Product();
            p.Name = prodName;
            p.UnitsInStock = unitsInStock;
            p.UnitPrice = unitPrice;

            pList.Add(p);

            p = null;
        }

        return pList;
    }
</code></pre>
