Don't use
ArrayList
, use
System.Windows.Collections.Generic.List
,
http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx[
^].
Non-generic classes were rendered obsolete in the .NET Framework v.2.0, when generics were introduced. They are still used in legacy code (and ware not formally marked with
Obsolete
attribute to avoid breaking of backward compatibility), but in new development they make no sense and bad because they require type cast.
Also, consider review of the code design to use
StringBuilder
in first place. The solutions using
foreach
are correct though.
—SA