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.