草庐IT

PixelsWide

全部标签

c# - 使用 LINQ,我能否验证一个属性对所有对象都具有相同的值?

我有一个Crate对象,它有一个KeyValuePairs列表。目前,我正在遍历每一对以查看列表中所有项目的kvp.Value.PixelsWide是否相同。如果是,则返回true,否则返回false。我现有的方法如下:publicboolValidate(Cratecrate){intfirstSectionWidth=0;foreach(KeyValuePairkvpincrate.Sections){if(firstSectionWidth==0)//firsttimeinloop{firstSectionWidth=kvp.Value.PixelsWide;}else//not

c# - 使用 LINQ,我能否验证一个属性对所有对象都具有相同的值?

我有一个Crate对象,它有一个KeyValuePairs列表。目前,我正在遍历每一对以查看列表中所有项目的kvp.Value.PixelsWide是否相同。如果是,则返回true,否则返回false。我现有的方法如下:publicboolValidate(Cratecrate){intfirstSectionWidth=0;foreach(KeyValuePairkvpincrate.Sections){if(firstSectionWidth==0)//firsttimeinloop{firstSectionWidth=kvp.Value.PixelsWide;}else//not