将IList转换为整数 [英] Convert IList to integer

查看:87
本文介绍了将IList转换为整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表,如

IList<BackPlanes> backplanes =
                  panel.Items.Where(x => x is BackPlanes).OrderBy(x => x.Index).Cast<BackPlanes>().ToList();





backplanes = backplanes - 1;



I我收到类似操作符的错误 - 无法应用于System.Collections.Generic.IList< domain.generatecontrols.backplanes>类型的操作数。和int。





backplanes = backplanes - 1;

I am getting an error like Operator - cannot be applied to operands of type System.Collections.Generic.IList<domain.generatecontrols.backplanes> and int.

foreach (KeyValuePair<double, double> drop in DrawFrame)
                                     {
                                        if (backplanes.Count <= 0) break;

                                         Shape framecabl = panelSheet.Drop(frameCable, drop.Key, drop.Value);
                                         framecabl.Text = terminalBoxSummary.ToString();
                                         backplanes = backplanes-1;
                                     }

推荐答案

正如我们所讨论的那样,你应该写:

As we discussed, then you should write:
if (backplanes.Count <= 0) break;





To删除你可以使用的第一个元素(而不是backplanes = backplanes-1;)



To remove first element you can use (instead of "backplanes = backplanes-1;")

backplanes.RemoveAt(0);

//or use following code:
for(int i=0; i< backplanes.Count; i++ )
{
// your operations here....
}





更多信息: http://msdn.microsoft.com/en-us/library/5cw9x18z.aspx [ ^ ]


这篇关于将IList转换为整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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