C# DataTable转化为string解决办法

C# DataTable转化为string
从SQL查询到数据DataTable,大致如下:
C# DataTable转化为string解决办法
下面的txt为想要得到的字符串
该怎么来写呢?
规则说明:
有个学科数组:
string[] ObjectList = {"语文", “数学”, “英语”};  // 实际上很多项

1、属于学科数组的字段按照(考点::字段)的方式显示,
2、不属于的只显示一次
3、有可能有字段为空,为空的字段直接忽略


public string DataTableToString(DataTable dt, string[] ObjectList)

自己写了下,很繁琐,还没写对~如何来做呢?万分感谢!
------解决方案--------------------
就是遍历,自己组装,先遍历行,然后遍历该行的cell
------解决方案--------------------
这你按自己的要求组装就行了
------解决方案--------------------
这个,循环输出不就OK了
for(int i=0;i<dt.rows.count;i++)
{
write2txt("名字="+dt.rows[i]["姓名"].tostring());
write2txt("年龄="+dt.rows[i]["年龄"].tostring());
write2txt("考点::"+dt.rows[i]["考点"].tostring()+"语文"+dt.rows[i]['语文'].tostring());
}
------解决方案--------------------
使用2重for循环搞定,不用定义什么学科数组
List<string> L=new List<string>();
for(int r=0;r<dt.rows.count;r++)
{
if(!L.contains(dt.rows[i][1].Tostring()+dt.rows[i][2].Tostring())
{
L.Add(dt.rows[i][1].Tostring()+dt.rows[i][2].Tostring())

str+=dt.columns[1].columnName+"="+dt.rows[i][1]+"\n";
str+=dt.columns[2].columnName+dt.rows[i][2]+"\n";
}
for(int l=4;l<dt.columns.count;l++)
{
str+=dt.rows[i][3]+"::"+dt.columns[l].columnName+"="+dt.rows[i][l]+"\n";
}
}