2013-03-11 29 views
1

如何檢查兩個ColorBlendsColors值不同?比較ColorBlends

我嘗試下面的代碼

ColorBlend Blend1 = new ColorBlend(); 
Blend1.Colors = new Color[] { Color.White, Color.Black }; 
Blend1.Positions = new float[] { 0.0f, 1.0f }; 

ColorBlend Blend2 = new ColorBlend(); 
Blend2.Colors = new Color[] { Color.White, Color.Black }; 
Blend2.Positions = new float[] { 0.0f, 1.0f }; 

if (Blend1.Colors != Blend2.Colors) 
{ 
    MessageBox.Show("Values are Different"); 
} 

它不工作,因爲當Colors值是兩個Blends一樣,它仍然說,他們是不相等!

回答

1

檢查不正確。你不能以這種方式比較兩個數組。 你必須去通過,並比較每個項目,以確保他們是平等的

+0

我不能使用循環或者是因爲有時一個混合有多種顏色那麼其他 – Adrao 2013-03-11 01:28:05

+0

這樣的回答可以幫助你:http://stackoverflow.com/questions/1673347/LINQ-確定-IF-2序列 - 包含-恰好最相同元素 – TGH 2013-03-11 01:32:37