StringBuilder Consume less memory than List<> in Generic

When I play around stringbuilder and list<> in generic I got small doubt in my mind. Which is takes less memory whether stringbuilder or list<>. However list<> is type safe even I eager to know which is takes less memory. Then i find out that stringbuilder takes less memory compare with list<> in generic.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            long byte1 = GC.GetTotalMemory(true);
            List<string> lst = new List<string>();
            long byte2 = GC.GetTotalMemory(true);
            Console.Write("List Initialize :");
            Console.WriteLine(byte2 - byte1);

            for (int i = 0; i < 100000; i++)
            {
                string value = i.ToString();
                lst.Add(value);
            }

            long byte3 = GC.GetTotalMemory(true);
            Console.Write("List size :");
            Console.WriteLine(byte3 - byte2);

            StringBuilder sb = new StringBuilder();
            long byte4 = GC.GetTotalMemory(true);
            Console.Write("StringBuilder Initialize :");
            Console.WriteLine(byte4 - byte3);

            for (int i = 0; i < 100000; i++)
            {
                string value = i.ToString();
                sb.Append(value);
            }

            long byte5 = GC.GetTotalMemory(true);
            Console.Write("StringBuilder size :");
            Console.WriteLine(byte5 - byte4);            
            Console.Read();
        }
    }
}


please correct me if i did any mistakes.
Ebook Download
View all
Learn
View all