string interning - should this code only create 10 strings in memory?

Posted by CodingThunder on Stack Overflow See other posts from Stack Overflow or by CodingThunder
Published on 2010-03-23T18:19:31Z Indexed on 2010/03/23 18:23 UTC
Read the original article Hit count: 148

Filed under:

Seems to create a lot more. Please advice why or how to intern correctly here.

Thanks

        IList<string> list = new List<string>(10000);

        for (int i = 0; i < 10000; i++)
        {
            for (int k = 0; k < 10; k++)
            {
                list.Add(string.Intern(k.ToString()));
            }
        }

        Console.WriteLine("intern Done");
        Console.ReadLine();

© Stack Overflow or respective owner

Related posts about c#