I have a question about interfaces.
I have an interface:
public interface myInterface {
void setField(string fieldName, object value);
}
Then a class that implements it:
public void MyClass: myInterface {
public void setField(string fieldName, object fieldValue) {
}
}
The programmer would then use the class like so:
MyClass t = new MyClass();
t.setField("userID", "10");
This is all find an dandy... but what I *really* want is for the user to be presented with a list of fields to choose from instead of needing to know the field name and be depended upon to spell it correctly.
The idea that would work perfectly would be an enumeration:
So now, my class definition becomes this:
public void MyClass: myInterface {
public enum Fields {
id,
userID,
firstName
}
public void setField(Fields fieldName, object fieldValue) {
}
}
And to use it:
MyClass t = new MyClass();
t.setField(MyClass.Fields.userID, "10");
Now my question is... how can I do that and make it work from the interface side of things? Is there a way to use generics? or some other way?
Thanks