André Freitas said:
Whats the best way to implement a dictionary like class who gets 3 columns.
Like:
"name", "regex", "error msg"
Or
"name", "reg" and "name", "error msg"
Regards,
André
Make a custom class that contains a regular expression and an error
message, and use in a dictionary:
public class InputSettings {
public string Regex { get; private set; }
public string ErrorMessage { get; private set; }
public InputSettings(string regex, string errorMessage) {
Regex = regex;
ErrorMessage = errorMessage;
}
}
var settings = new Dictionary<string, InputSettings>();
settings.Add(
"name", new InputSettings(
".+", "Name has to be at least three characters."
)
);
settings.Add(
"email", new InputSettings(
"@", "The email address is incomplete."
)
);
Now you can efficiently look up the settings based on the control name.