转换的DataGridViewRow为String [英] Convert DataGridViewRow to String
问题描述
我有一个的DataGridViewRow
,我想将其转换为字符串格式如下所述:
I have a DataGridViewRow
and I want to convert it to a string in the format mentioned below:
电池[0]的ToString()+\ t+细胞[1]的ToString()+\ t+ ... +细胞[N]的ToString()
其实我想这在的DataGridViewRow
每个单元格的字符串值之间的字符串和 \ t
它们。
In fact I want a string which has the string values of each cell in DataGridViewRow
and a \t
between them.
什么是最好的清洁和可读的方式?使用循环和检查情况的唯一途径?第一个解决办法是增加每个单元与 \ t
到一个临时字符串,然后删除临时串的最后一个字符。
what is the best clean and readable way? Is using loop and checking the condition is the only way? the first solution would be to add each cell with \t
to a temp string and then remove the last character of the temp string.
推荐答案
每当它的循环,LINQ就派上用场了。
Whenever it's loops, LINQ comes to the rescue.
string.Join("\t", cell.Select(c => c.ToString()).ToArray())
这篇关于转换的DataGridViewRow为String的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!