先创建一个对象,有ID和Re字段;然后实例化List<T>;最后循环长字符串添加到集合中! 

解决方案 »

  1.   

    这个东西,直接遍历string中的字符,设置各起始位置,用substring取就是了
      

  2.   

                    int i=0;
                    List<string> lst = new List<string>();
                    string substr="长字符串";
                    string str="40的字符串";
                    while(substr.Length>0)
                    {
                        if(substr.Length>40)
                        {
                            str = substr.Substring(i * 40, (i + 1) * 40);
                            substr = substr.Substring((i + 1) * 40);
                        }
                        else
                        {
                            str = substr;
                            substr = string.Empty;
                        }
                        lst.Add(str);
                    }把List类型换掉即可。id=i;
      

  3.   

    还是自己搞了,想看看有没有更简便的方法、还是得自己根据逻辑截取。 int j = 1;
                //    ComUwPolicy uw = new ComUwPolicy();
                //    int a = modPage.DataContent.Trim().ToString().Length % 40;
                //    string str_temp = "";//记录截取的字符串
                //    for (int i = 0; i < modPage.DataContent.Trim().ToString().Length; i++)
                //    {
                //        str_temp = str_temp + modPage.DataContent.Trim().Substring(i, 1);
                //        if ((i % 40) == 0 && i > 0)
                //        {
                //            UwEngage enage = new UwEngage();
                //            enage.ClauseCode = "T0001";
                //            enage.ClauseName = "特别约定";
                //            enage.Clauses = str_temp;
                //            enage.SerialNo = j;
                //            j++;
                //            str_temp = "";
                //            uw.Engages.Add(enage);
                //        }
                      
                //    }
                //    if (modPage.DataContent.Trim().Length % 40 != 0)
                //    {
                //        UwEngage enage = new UwEngage();
                //        enage.ClauseCode = "T0001";
                //        enage.ClauseName = "特别约定";
                //        enage.Clauses = modPage.DataContent.Trim().Substring(modPage.DataContent.Length - modPage.DataContent.Length % 40, modPage.DataContent.Length % 40);
                //        enage.SerialNo = j;
                //        uw.Engages.Add(enage);
                //    }