Time for action – consuming our new Extension method

Now, let's see how we can consume this method:

  1. Stay in the project you created. Add a console application. Call it StringExTest.
  2. Add a reference of StringEx class library to this project:
    Time for action – consuming our new Extension method
  3. Add the following using directive in Program.cs:
    using StringEx;
  4. Add the following string variable in the Main() method. This validates Swedish zip codes:
    string pattern = @"^(s-|S-){0,1}[0-9]{3}\s?[0-9]{2}$";
  5. Add a few test input strings in a List of strings:
    List<string> testInputs = new List<string>() {"12345", "425611", "932 68", "S-621 46", "5367", "31 545" };

    Iterate through all these test inputs to find out whether ...

Get .NET 4.0 Generics now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.