James Manning's Blog

February 21, 2010

List<string> should format args for me

Filed under: Uncategorized — manningj @ 8:30 pm

I was building up a list of status messages which i was going to have to build with string.concat’s or (more likely) string.format calls, so instead I just added an overload for the case where additional args are passed in.  Much nicer :)

public static void Add(this List<string> self, string format, params object[] args)
{
    self.Add(String.Format(format, args));
}

1 Comment »

  1. [...] that previous post about List<string>.Add?  Well, one of the uses of the messages was to get into an [...]

    Pingback by James Manning » attaching a collection of strings to an email as a text file — February 22, 2010 @ 6:57 pm


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.