在你们的帮助下,我创建了一个类似于经典asp中的记录集的对象。
public class RecordSet: List<Dictionary<string, object>>
{
}
所以我可以访问如下数据:
RecordSet rs = new RecordSet();
rs[rowID]["columnName"];
我怎样才能获得这样的访问权限,即序数引用:
rs[rowId][2];
请不要问我为什么不使用数据表,这部分是为了娱乐、学习和测试呵呵
最佳答案
更像 RecordSet 的东西可能看起来像这样:
public class RecordSet {
private Dictionary<string, int> _nameLookup;
private List<List<object>> _rows;
private int _currentRow;
...
public object this[int index] {
return _rows[_currentRow][index];
}
public object this[string name] {
return this[_nameLookup[name]];
}
...
}
关于c# - 经典的asp类似记录集对象,如何在.net中设计它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/681722/