2005-04-25

MSN Messenger + .NET 2.0

I just had this crazy idea: what if the next version of MSN Messenger would be written in .NET 2.0? Wouldn't it be cool if MSN Messenger had:I think it would definitely make .NET 2.0 very popular. And it would create a whole new market: MSN Messenger plugins (games and other applications that use the MSN Messenger platform).

2005-04-19

Opera 8 Released

Opera 8 has finally been released, after 3 betas. I must say, this version is a major release. Previous versions really can't compare to it. If you haven't used it before, please try it out.
Tags: , Browsers.

2005-04-02

Fast .NET formatting of values

I see people use string.Format(formatProvider, "{0}", value) or string.Format(formatProvider, "{0:formatSpecifier}", value), just to format a value (int, double, ...). I used to do this to, until I looked at how string.Format works (using Reflector). Apparently, a StringBuilder-object is created, and the "{0:...}" is parsed, a lot of appending happens and finally the stringBuilder.ToString() is returned. Here's a function that does the same. Basically, it just does the same as inside StringBuilder.AppendFormat, but without all the parsing, creating and appending. It's a lot faster, and creates less temporary objects.
public static string Format(object value, IFormatProvider formatProvider, string formatSpecifier)
{
   if (formatSpecifier.Length == 0)
      return value.ToString();

   if (formatProvider == null)
      formatProvider = System.Globalization.CultureInfo.CurrentCulture;

   ICustomFormatter formatter = formatProvider.GetFormat(typeof(ICustomFormatter)) as ICustomFormatter;
   if (formatter != null)
      return formatter.Format(formatSpecifier, value, formatProvider);

   IFormattable formattable = value as IFormattable;
   if (formattable != null)
      return formattable.ToString(formatSpecifier, formatProvider);

   return value.ToString();
}
Tags: .