zoukankan      html  css  js  c++  java
  • 修改已有数据的DataTable的字段类型

    //将int类型的字段改为string类型          

    DataTable dtResult = new DataTable();
                dtResult = dt.Clone();
                foreach (DataColumn col in dtResult.Columns)
                {
                   col.DataType = typeof(String);
                }
                for (int i = 0; i < dt.Rows.Count ; i++)
                {
                    DataRow rowNew = dtResult.NewRow();
                    for (int j = 0; j < dt.Columns.Count ; j++)
                    {
                            if (Convert.ToInt32(dt.Rows[i][j]) == 0)
                            {
                                rowNew[j] = "不开考";
                            }
                            else if (Convert.ToInt32(dt.Rows[i][j]) == 1)
                            {
                                rowNew[j] = "开考";
                            }             
                    }
                    dtResult.Rows.Add(rowNew);
                }

  • 相关阅读:
    Vue.js
    Vue.js
    Vue.js
    Vue.js
    webpack(1)
    webpack(2)
    babel-loader7和babel8版本的问题
    [JZOJ4274] 终章-剑之魂
    [JZOJ427] 圣章-精灵使的魔法语
    BZOJ题表(红色表示已完成)
  • 原文地址:https://www.cnblogs.com/hobby0524/p/7122207.html
Copyright © 2011-2022 走看看