Get Strings

Giganews Newsgroups
Subject: Get Strings
Posted by:  Shapper (mdmou…@gmail.com)
Date: Thu, 30 Aug 2012

Hello,

On a application I need to obtain a few String values.

I have two distinct situations which I will describe:

1) In the case the Strings have only one version I am doing the following:

  public static class RegexFactory {
    public const String Password = @"^(\w|\-)*$";
    public const String Username = @"^(\w|\-)*$";
  } // RegexFactory

    So I use it simply as follows: RegexFactory.Password();

    Note: I am not sure if RegexFactory is a good name for this ...

              Maybe RegexProvider?

    And should I use Static Properties instead of Consts?

2) I have other situations where one String might have two values.

    Consider I have an argument which affects which value of Password I will get.

    If argument passed = A then return RegexFactory.Password returns "X".

    If argument passed = B then return RegexFactory.Password returns "Y".

    ...

    Basically, I need to have a "table" argument,field that does the association:

    Password: A > X, B > Y, C > Z, ...

    Username: A > 1, B > 2, C > 3, ...

    Which approach would you use?

Note: Theses classes (Both 1 and 2) are used often in my application.

Thank You,

Miguel

Replies