我不明白这段代码:( [英] i dont understand this code:(

查看:70
本文介绍了我不明白这段代码:(的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们
我不懂这段代码
你能解释一下PLZ吗?
tnx

hi guys
i dont understand this code
can you explain plz
tnx

for (int i = 0; i<listBox1.SelectedItems.Count; i++)
            {
                listBox1.Items.Remove(listBox1.SelectedItems[i].ToString());
                i--;
            }

推荐答案

这是您刚刚用来回答问题的代码吗?您不了解哪一点?这是多余的,而且做起来很糟糕,我总是为0,只是集合缩小以满足它.循环应从计数-1到0运行,从而使i--变得多余.

这段代码写得不好,但是对于任何知道C#的人来说,它都是自我记录的.您是在做课程还是在教自己?您显然不是编码人员.
IS this the code you were just given to answer your question ? Which bit don''t you understand ? It is kind of redundant, and a poor way of doing it, i always is 0, it''s just that the collection shrinks to meet it. The loop should run from count -1 to 0, making the i-- redundant.

This code is poorly written, but it''s self documenting for anyone who knows ANY C#. Are you doing a course or teaching yourself ? You''re obviously not working as a coder.


这篇关于我不明白这段代码:(的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆