Also below I am try to compare Enumeration value, for some reason the statement is dropping into the condition which is not valid. Because the value equal to each other when I step into the code. So it should not jump into the case below.
prevColorOn.Type = On
ColorType.ColorOn = On
if (prevColorOn.Type != ColorType.ColorOn)
{
throw new ArgumentException("prevColorOn", "Did not recieved expected ColorType'prevColorOn'.");
}
Loading

Posted Aug 7, 2013, 9:33 PM EDT
David SmithRank #999 · 2K reputationPosted Aug 8, 2013, 11:10 AM EDT
prevColorOn = GetColorInfo((string)en.Current);
if ((int)prevColorOn.Type != (int)ColorTimeType.On)
{
throw new ArgumentException("prevColorOn.Type", "Did not recieved expected ColorTimeType 'prevColorOn'.");
}
Posted Aug 8, 2013, 8:43 PM EDT
David SmithRank #999 · 2K reputationPosted Aug 9, 2013, 12:06 AM EDT
enum ColorType
{
ColorOn,
ColorOff
}
Posted Aug 9, 2013, 12:18 AM EDT
What is the data type of prevColorOn ? Is it an enum?
David SmithRank #999 · 2K reputationPosted Aug 12, 2013, 8:36 AM EDT
Its a color object I created. In the color object
there exist a enum ColorType. review below
enum ColorType
{
ColorOn,
ColorOff
}
public class Color
{
private ColorType type = ColorType.On;
///
/// Gets or sets the color type. (On|Off)
///
///
/// The type.
///
public ColorType Type
{
get
{
return type;
}
set
{
type = value;
}
}
}
Jignesh TrivediRank #16 · 50.3K reputationPosted Aug 12, 2013, 7:09 PM EDT
i think is some thing is wrong while you assigned default value in you class to on.
try using auto implemented property.
public class Color
{
public ColorType Type { get; set; }
// construcor of class
public Color()
{
this.Type = ColorType.On;
}
}
hope this will help you.
VulpesRank #55 · 29.2K reputationPosted Aug 12, 2013, 10:58 PM EDT
So this line:
private ColorType type = ColorType.On;
should be:
private ColorType type = ColorType.ColorOn;
Subject to that, your original 'if' statement should work fine:
if (prevColorOn.Type != ColorType.ColorOn)
{
throw new ArgumentException("prevColorOn", "Did not recieved expected ColorType'prevColorOn'.");
}