C# List<string[]> 数据处理

编写下面的函数,程序要求如下,将ExDat的 ExcelRow行,替换至myData的RowFromNum到RowToNum行,第ColNum列,
private bool LFDoDataProcess(List<string[]> myData,List<string[]> ExDat, int RowFromNum, int RowToNum, int ColNum, int ExcelRow)
{
try
{
//这里是要编写代码的位置
return true;
}
catch (Exception ex)
{
return false;
}
}
如图所示

using System;
using System.Collections.Generic;
namespace ConsoleApplication1
{
    class Program
    {
        static List<string[]> d1 = new List<string[]>();
        static List<string[]> d2 = new List<string[]>();
        static void Main(string[] args)
        {
            d1.Add(new string[] { "a1", "a2", "a3" });
            d1.Add(new string[] { "a4", "a5", "a6" });
            d1.Add(new string[] { "a7", "a8", "a9" });
            d2.Add(new string[] { "b1", "b2", "b3" });
            d2.Add(new string[] { "b4", "b5", "b6" });
            d2.Add(new string[] { "b7", "b8", "b9" });
            LFDoDataProcess(d1, d2, 1, 3, 2, 2);
        }
        static private bool LFDoDataProcess(List<string[]> myData, List<string[]> ExDat, int RowFromNum, int RowToNum, int ColNum, int ExcelRow)
        {
            //将ExDat的 ExcelRow行,替换至myData的RowFromNum到RowToNum行,第ColNum列。
            try
            {
                //这里是要编写代码的位置  
                    for (int row = 0; row < RowToNum - RowFromNum + 1; row++)
                    {
                        myData[RowFromNum - 1 + row][ColNum - 1] = ExDat[ExcelRow - 1][row];
                    }
                return true;
            }
            catch (Exception ex) //ex是否多余?
            {
                return false;
            }
        }
    }
}

给出整个控制台程序代码。

温馨提示:答案为网友推荐,仅供参考
相似回答