Company      |       Articles & Research      |      Services      |      Software      |      Contact

Building an ErrorCollection Class

Ever notice how its always the smallest code tasks that take the longest to solve? Thats how it is with me!

I am working on an emailing program and I wanted to be able to build an ErrorCollection class, inheriting from the StringCollection base class since it would allow the representation of a set of strings. I was stupidly calculating the length of the strings wrong though and just wasted 45 minutes this morning.

C#:
  1. ErrorCollection errors = new ErrorCollection();
  2. StringEnumerator enumerator = base.GetEnumerator();
  3. while (enumerator.MoveNext())
  4. {
  5. string rString = enumerator.Current.Replace("\r\n", "
  6. ");
  7. if ((rString.LastIndexOf("
  8. ") == -1) || (rString.LastIndexOf("
  9. ") != rString.Length))
  10. {
  11. rString = rString + "
  12. ";
  13. }
  14. errors.Add(rString);
  15. }
  16. return errors;

Bah!

share save 171 16 Building an ErrorCollection Class

Related posts:

  1. ASP.NET Provider Exceptions (ProviderException)
  2. ToolPart Class With System.Reflection
  3. How To Use PolicyLevel Objects For Display And Debugging
  4. Using DescriptionAttribute And Reflection For Building Typed Collections Off Enumerations
  5. Building A Simple SharePoint 2007 / WSS v3 WebPart

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment