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
VulpesPosted Aug 13, 2013, 2:58 AM
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'.");
}
Jignesh TrivediPosted Aug 12, 2013, 11:09 PM
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.
David SmithPosted Aug 12, 2013, 12:36 PM
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;
}
}
}
Posted Aug 9, 2013, 4:18 AM
What is the data type of prevColorOn ? Is it an enum?
David SmithPosted Aug 9, 2013, 4:06 AM
enum ColorType
{
ColorOn,
ColorOff
}
Posted Aug 9, 2013, 12:43 AM
David SmithPosted Aug 8, 2013, 3:10 PM
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, 1:33 AM