From: Göran Andersson on
Andr� Freitas wrote:
>>> 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.
>>
>> --
>> G�ran Andersson
>> _____
>> http://www.guffa.com
>
>
> Can you show me how can I use it?
>
> Thank you.
>

To get the settings for a name:

InputSettings emailSettings = settings["email"];

--
G�ran Andersson
_____
http://www.guffa.com
First  |  Prev  | 
Pages: 1 2 3
Prev: Popup if change in gridview
Next: Hotfix