using System; using System.Collections.Generic; using System.Diagnostics; namespace Test { class Program { static string[] m_Data = { "A", "B", "C", "D", "E", "A1", "B1" }; static void Main(string[] args) { GC.Collect(); Stopwatch watch = new Stopwatch(); using (new AutoWatch(watch)) { Fe1(); } Console.WriteLine(watch.ElapsedTicks); } static void Fe1() { List<string> list = new List<string>(); List<string> temp = new List<string>(); List<string> result = new List<string>(); int n = m_Data.Length; string t; string sEnd = m_Data[n - 1]; int i = 0; while (i < n) { t = m_Data[i]; temp.Add(t); foreach (string s in list) { //Console.WriteLine(t + s); result.Add(t + s); temp.Add(t + s); } list.AddRange(temp); temp.Clear(); i++; } } public sealed class AutoWatch : IDisposable { private Stopwatch watch; public AutoWatch(Stopwatch watch) { this.watch = watch; watch.Start(); } void IDisposable.Dispose() { watch.Stop(); } } } }