Tech Off Thread

7 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Regular Expression on a passed ArrayList, C#

Back to Forum: Tech Off
  • User profile image
    DesignMail

    I am passing an ArrayList successfully from my boundary class to the control class. I need to error handle the data so I created an ErrorHanlder that would handle the Regex.
    How do I pull the elements of the ArrayList out and run Regex on them?

    Thank you for your time
    Steve
    Cool

  • User profile image
    JoshB

    huh?

    try
    {
     ...
    }
    catch (Exception e)
    {
       foreach (String s in YourArrayList)
       {
             RegEx.Match(s, blah)
       }
    }

    Something like that. Assuming you have Strings in your array list.

  • User profile image
    DesignMail

    [H]I have some strings in the ArrayList. Most of the data is a combination of DateTime and doubles as well as decimals.
    Was the Huh? about the boundary controller stuff?

    Steve

  • User profile image
    figuerres

    DesignMail wrote:
    [H]I have some strings in the ArrayList. Most of the data is a combination of DateTime and doubles as well as decimals.
    Was the Huh? about the boundary controller stuff?

    Steve


    well some of your first post was not really clear.

    also it sounds like an ArrayList and your data are not really a good design.... 

    why does the list contain different "Types of" data ??

    if you have no other options then you are going to have to do some work to make it work...

    for example :

    look up the Type methods in .net for how to find the "type" of an object and then based on the type determine what to do.

    for example a
    switch(){
      case : {}
    }

    where the switch is on the Type and each case handles a type
    for some you use the RegEx and for other do what ever...

    but most of the time an ArrayList is not the way to go unless you have no options.

  • User profile image
    DesignMail

    I have since found the needed code and the ArrayList design flaw you mentioned has been abandoned. I have since used a try catch that could account for most of the trouble that I was having. I only have to account for a single string (clientName).
    Thank you for your response.
    Cool
    Thank you for your time
    Steve

  • User profile image
    DesignMail

    Thanks Josh I have seen fixed the trouble and only have a single string (clientName) to work with.

    Thank you for your time
    Steve[H]

  • User profile image
    JoshB

    DesignMail wrote:
     so I created an ErrorHanlder that would handle the Regex
    Cool


    I wasn't sure what the error handler was actually trying to catch. That's all. Glad to hear you got it worked out.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.