替换所有空格
Entity.Name = Regex.Replace(dt.Rows[i]["行政值日"].ToString().Trim().Replace(" ", "").Replace(" ", ""), @"\s", ""); Entity.Riqi = dt.Rows[i]["日期"].ToString().Trim().ToDateTime().ToString("yyyyMMdd"); Entity.Leader = Regex.Replace(dt.Rows[i]["行政值日"].ToString().Replace(" ","").Replace(" ","").Trim(), @"\s", ""); Entity.Teacher = Regex.Replace(dt.Rows[i]["老师值日"].ToString().Trim(), @"\s", "");