如何阅读pariculor row&使用c#从数据表中获取列数据 [英] how to read pariculor row & column data from datatable using c#

查看:98
本文介绍了如何阅读pariculor row&使用c#从数据表中获取列数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望从带有for循环条件的数据表中读取一些数据。在该数据表中,我希望在某些行(10到15)和(第5到10行)的帮助下读取一些特定的行和列数据



I want read some of data from datatable with for loop condition .in that datatable I want read some particular rows and column data with help of some row no (10 to 15) and (column no 5 to 10)

DataTable tbl = new DataTable();




for(tbl.row=10; tbl.row<=15;tbl.row++)
         {
                 for(tbl.colum=5; tbl.colum<=10;lt;=15;tbl.colum++)
                       {
                          string cell=[tbl.row].[tbl.colum]
                         }
           }

推荐答案

//dataTab is the datatable

//reading all the data for all rows and columns.
for (int j = 0; j < dataTab.Rows.Count; j++)
{
    for (int i = 0; i < dataTab.Columns.Count; i++)
    {
        Console.WriteLine(dataTab.Rows[j][i]);
    }
}

//Reading data for rows 10 to 15 and columns 5 to 10
//j is used for rows
for (int j = 9; j < 15; j++)
{
    //i is used for columns
    for (int i = 4; i < 10; i++)
    {
        Console.WriteLine(dataTab.Rows[j][i]);
    }
}


这篇关于如何阅读pariculor row&amp;使用c#从数据表中获取列数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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