ExtensionMethod.NET Home of 876 C#, Visual Basic, F# and Javascript extension methods


combin datarow's field value to string


public static string ItemArrayString(this DataRow dr, string separator)
	return string.Join(separator, dr.ItemArray);

public static string ItemArrayString(this DataRow dr)
	return string.Join(",", dr.ItemArray);


DataTable dt = new DataTable("test");
dt.Columns.Add("ID", typeof(int));
dt.Columns.Add("NAME", typeof(string));
dt.Columns.Add("SURNAME", typeof(string));
dt.Rows.Add(1, "Rainmaker", "MIKE");
DataRow dr = dt.Rows[0];
string drValues = drValues = dr.ItemArrayString(); // 1,Rainmaker,MIKE
drValues = dr.ItemArrayString(","); // 1,Rainmaker,MIKE

Author: RainmakerHo

Submitted on: 26 apr. 2013

Language: C#

Type: System.Data.DataRow

Views: 5388