登录社区云,与社区用户共同成长
邀请您加入社区
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(); } } } }
更多推荐
TestStar | 接入 AIUI 测试 30 天后,别拿别人的数算自己的账
SQL 必知必会:手把手教你掌握 MySQL 开窗函数的 4 大核心场景(附代码)
用 AIUI 打造「免手出行助手」——一篇能跟着做完的智能体实战教程
扫一扫分享内容
为遵守国家网络实名制规定,未绑定将限制内容发布与互动
所有评论(0)