使用循环如何在C#中用行连接列 [英] using loop how to concate columns with rows in C#

查看:70
本文介绍了使用循环如何在C#中用行连接列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Datagridview如下





Datagridview as follows


Student      English     Tamil    Maths    Science    Social

   A            70         75       80        90        75
   B            60         55       70        85        60
   C            50         60       70        75        63





使用for循环,从上面的Datagridview我想要如下







using for loop, from the above Datagridview i want as follows


A  Englsih 70,Tamil 75,Maths 80,Science 90,Social 75
B  Englsih 60,Tamil 55,Maths 70,Science 85,Social 60
C  Englsih 50,Tamil 60,Maths 70,Science 75,Social 63







我怎样才能在asp.net中使用C#。



问候,

Narasiman P.




how can i do in asp.net using C#.

Regards,
Narasiman P.

推荐答案

我们不做你的作业:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!



想一想:暂时忽略标题,单独考虑内容。

那是一个每一行的循环 - 很容易就是一个 foreach

然后你需要第二个循环遍历列 - 这可能是一个用于,因为你想特别处理第一个。



那么,当你有这个工作时,包括列信息与单元格内容。这并不难,只需要一点思考。
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

Think about it: ignore the headers for a moment, and think about the content alone.
That's one loop for each row - which can easily be a foreach
Then inside that you need a second loop to go through the columns - this one could be a for because you want to handle the first one specially.

Then, when you have that working, include the column info with the cell content. It's not difficult, it just takes a little thinking about.


这篇关于使用循环如何在C#中用行连接列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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