当前位置:网站首页>C# List. Can foreach temporarily / at any time terminate a loop?
C# List. Can foreach temporarily / at any time terminate a loop?
2022-06-11 22:44:00 【Simple tutorial】
C# List.ForEach Can temporarily / Stop the loop at any time ? This question really stumps me
int len = 0; List<string> aaa = new List<string>(){ "aaa", "bbb" }; aaa.ForEach(s => len += s.Length);
Look up the , The answer is You can't
If you want to temporarily exit , have access to foreach keyword
int len = 0; List<string> aaa = new List<string>(){ "aaa", "bbb" }; foreach(var s in aaa) { len += s.Length; break; }
边栏推荐
猜你喜欢
随机推荐
0-1 knapsack problem of dynamic programming (detailed explanation + analysis + original code)
链表基本操作与题型总结
5. Xuecheng project Alipay payment
二叉树的基本操作与题型总结
Exercise 8-8 judging palindrome string (20 points)
MATLAB点云处理(二十五):点云生成 DEM(pc2dem)
小程序启动性能优化实践
[bitbear story collection] February MVP hero story open source with love
Library management system
Unity中使用调用Shell的命令行
华为设备配置HoVPN
[Matlab]二阶节约响应
Toyota suppliers shut down Japanese factories due to cyber attacks, NVIDIA counterattacks extortion gangs to prevent data leakage | global cyber security hotspot on March 1
习题11-3 计算最长的字符串长度 (15 分)
論文閱讀《Dense Visual SLAM for RGB-D Cameras》
Simple example of logistic regression for machine learning
2022 online summit of emerging market brands going to sea will be held soon advance AI CEO Shou Dong will be invited to attend
[Yu Yue education] calculus of Zhejiang University in autumn and winter 2021 (I) reference materials
Tkinter study notes (IV)
习题6-6 使用函数输出一个整数的逆序数 (20 分)









