转换的DataGridViewRow为String [英] Convert DataGridViewRow to String

查看:201
本文介绍了转换的DataGridViewRow为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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆