CurrentItem
public class MyClass { private DataTable _mainDataTable; private List<Item> _items; public class Item { public Item() { } public int Id { get; set; } public string Title { get; set; } public string Description { get; set; } public bool Enabled { get; set; } } private MyClass() { } public DataTable MainDataTable { get { if (_mainDataTable == null && _items != null) _mainDataTable = _items.ConvertToDataTable<Item>(); return _mainDataTable; } set { _mainDataTable = value; } } public List<Item> Items { get { if (_items == null && _mainDataTable != null) { _items = _mainDataTable.ConvertToListOfItems<Item>(); } return _items; } set { _items = value; } } public int CurrentItemIndex { get; set; } public Item CurrentItem { get { if (Items == null || Items.Count == 0 || CurrentItemIndex + 1 > Items.Count) return new Item(); return Items[CurrentItemIndex]; } } }
Myclass obj=new Myclass(); int id=obj.CurrentItem.Id;
Myclass obj=new Myclass(); int id=obj.Id;