for fill for fill数据集值 [英] for loop for fill dataset values

查看:96
本文介绍了for fill for fill数据集值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

heyy ......

我有值的数据集...我想把它放在forloop ..你可以帮助我..





ds.Tables [0] .Rows [1] [2] =40;

ds.Tables [0] .Rows [2 ] [3] =40;

ds.Tables [0] .Rows [3] [4] =40;

ds.Tables [0] .Rows [2] [2] =41;

ds.Tables [0] .Rows [3] [3] =41;

ds。表[0] .Rows [3] [2] =42;

heyy...
I have dataset of values ...I want to put this in a forloop..can you help me..


ds.Tables[0].Rows[1][2] = "40";
ds.Tables[0].Rows[2][3] = "40";
ds.Tables[0].Rows[3][4] = "40";
ds.Tables[0].Rows[2][2] = "41";
ds.Tables[0].Rows[3][3] = "41";
ds.Tables[0].Rows[3][2] = "42";

推荐答案

// Get the data table.
   foreach (DataRow row in ds.Tables[0].Rows) // Loop over the rows.
   {

       foreach (var item in row.ItemArray) // Loop over the items.
       {
                  //do actions or assign values
                   item="something"
       }
   }





或替代for





or alternative with for

for (int i = 0; i < table.Rows.Count; i++)
           {
               for (int j=0;j<table.Columns.Count;j++)
               {
                   Console.WriteLine(table.Rows[i][j]);
               }
           }


这篇关于for fill for fill数据集值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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