using System; using System.Collections.Generic; using System.Text; namespace HTEXScan.Models { /**学生id数据**/ class SidData { /**col**/ public int Col { get; set; } /**值**/ public char Text { get; set; } } /**学生id**/ class Sid { /**max col**/ private int maxCol = 0; /**学生id缓存数据**/ private List datas = new List(); /**添加**/ public void Add(int col, char text) { SidData data = new SidData(); data.Col = col; data.Text = text; this.datas.Add(data); if (col > maxCol) maxCol = col; } /**获取**/ public List Get() { List ids = new List(); char[] dats = new char[maxCol]; this.GetData(ids, dats, 1); return ids; } /**获取**/ private void GetData(List ids, char[] dats, int col) { if(col > this.maxCol) { ids.Add(new string(dats)); } else { for(int i = 0;i < this.datas.Count;i++) { if (this.datas[i].Col == col) { dats[col - 1] = this.datas[i].Text; this.GetData(ids, dats, col + 1); } } } } } }