如何将字符串转换为字符串以列出strig [英] How to convert a string to string to list strig
本文介绍了如何将字符串转换为字符串以列出strig的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将数据表的字符串(行)与另一个数据表的其他字符串(行)进行比较
我正在使用以下代码来执行此操作
Hi,
I am comparing a string(row) of data table to other string(row) of another data table
I am using the folowing code to do that
foreach (DataRow row in lstDS1[0].Tables[0].Rows)
{
//string msgsGY;
List<string> msgsGY = new List<string>();
string fieldFromDB = row[1].ToString();
string FromDB = row[2].ToString();
foreach (DataRow row1 in lstDS1[1].Tables[0].Rows)
{
string fieldFromDB1 = row1[1].ToString();
if (fieldFromDB == fieldFromDB1)
{
msgsGY = fieldFromDB.ToList();
xlWorkSheet1.Cells[i, 1] = row[1];
xlWorkSheet1.Cells[i, 2] = row[13];
xlWorkSheet1.Cells[i, 3] = row1[13];
xlWorkSheet1.Cells[i, 4] = 10.ToString();
xlWorkSheet1.Cells[i, 5] = (Convert.ToDouble(row[13]) + Convert.ToDouble(row1[13])) + Convert.ToInt32(10);
i++;
}
}
}
如果字符串相等,我需要将它们放入列表字符串或字符串数组中并查看计数
我正在尝试这样的事情
If the strings are equal, I need to place them into list string or string array and see the count
I am trying something like this
List<string> msgsGY = new List<string>();
msgsGY = fieldFromDB.ToList();
但我在上面的行中收到错误。
有谁能帮我解决这个问题?
谢谢
John
But I am getting error in the above line.
Can anyone help me in solving this??
Thanks
John
推荐答案
试试这个;
Try this instead;
List<string> msgsGY = new List<string>();
...
msgsGY.Add(fieldFromDB);
这篇关于如何将字符串转换为字符串以列出strig的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文