Stacked Stacked - 1 year ago 187
C# Question

C# Array.ConvertAll for compact framework

As far as I know there is no Array.ConvertAll() for the compact framework. What is the best way to do an Array.ConvertAll in the CF?

public static string DataRowToString(DataRow dr)
return dr["columns"].ToString();

public static string[] DataTableToArray(DataTable dt)
var dr = dt.Select();
string[] strArr = Array.ConvertAll(dr, new System.Converter<DataRow, string>(DataRowToString));
return strArr;

The code above doesn't work in CF.

Answer Source

You can use a LINQ expression:

var result = input.Select(converter).ToArray();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download