I ended up solving the problem as follows. This will let me create a
property containing any simple values, without knowing the value types, and
making updates as necessary. Please let me know if you see any flaws.
Thanks for all the input. It was educational.
--------------------------------------------------------
public abstract class MyProperty {
protected const int current = 0;
protected const int proposed = 1;
protected object[] values = new object[2];
public MyProperty(object myValue) { values[current] = myValue; }
public object Value {
get { return values[proposed]; }
set { values[proposed] = value; }
}
public abstract bool Valid {get;}
public void commit () { if (this.Valid) Array.Copy(values, 1, values, 0,
1); }
public void reset () { Array.Copy(values, 0, values, 1, 1); }
public void display (string msg) { ... }
}
"Bob Weiner" <bo*@engr.uconn.edu> wrote in message
news:uC**************@TK2MSFTNGP09.phx.gbl...
This seems real simple but I don't know how to do it. Obviously, what I'm
looking for isn't what I typed.
I don't want the assignment operator in commit() and reset() to work by
reference but System.Object doesn't have a copy or clone method available.
I'm sure I'm missing something simple.
public class MyProperty {
private object currVal;
private object newVal;
public MyProperty(object initialValue) {}
public abstract object Value { get; set; }
public void commit () { currVal = newVal; }
public void reset () { newVal = currVal; }
}