public static string DataRowToString(DataRow dr)
{
return dr["columns"].ToString();
}
public string [] DataTableToArray(DataTable dt)
{
DataRow[] dr = dt.Select();
string [] strArr= Array.ConvertAll(dr, new Converter
return strArr;
}
Array.ConvertAll() function simply converts the array of one to another so here in above example we are passing dr as an araay of datarows in first arguments. second argument is a Converter delegate type which convert one type to another so in this we will pass a link to delegate which is DataRowToString() function ,the delegate should know the input datatype and output datatype which is datatrow and string in this case respectively. function DataRowToString noe simply takes a datarow and return the string value for the column specified. which can be extended for multiple columns also.
Ref: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/46ef6ca8-7f66-489a-a0f6-b6b7c4200d16
No comments:
Post a Comment