What is wrong with this code?
What is the result of this code?
Hint: Open this up in the debugger and check the result of "Value != defaultValue", and then run the code.
using System;
using System.Reflection;
public class TestFailure
{
public cascadeStyle cascadeStyleField;
private FieldInfo field;
private object defaultValue;
public static void Main(string [] args)
{
new TestBooleanMath().Run();
}
public void Run()
{
field = typeof(TestFailure).GetField("cascadeStyleField");
defaultValue = cascadeStyle.none;
cascadeStyleField = cascadeStyle.none;
bool hasValue = Value != defaultValue;
Console.WriteLine(hasValue);
}
public object Value
{
get { return field.GetValue(this); }
}
public enum cascadeStyle
{
all,
none,
delete
}
}
I'll post the answer tomorrow.
Comments
Comment preview