Usuwanie obiektu z listy

0
class CheckedItems
    {
        public string _position { get; private set; }
        public int _id { get; private set; }

        public CheckedItems(string position, int id)
        {
            _position = position;
            _id = id;
        }
    }

class CheckedListBoxValues
    {
        public string CheckedListBox { get; private set; }
        public DataTable DTable { get; private set; }
        public List<CheckedItems> ChkdItems = new List<CheckedItems>();

        public CheckedListBoxValues(string _CheckedListBox, DataTable _DTable)
        {
            CheckedListBox = _CheckedListBox;
            DTable = _DTable;
        }

        public void AddCheckedItem(string _position,int _id)
        {
            ChkdItems.Add(new CheckedItems(_position, _id));
        }

        public void RemoveCheckedItem(int id)
        {
            CheckedItems ci = ChkdItems.Where(ci => ci._id==id).Single();
            
        }
    }

Przy kompilacji dostaje błąd

Error 1 A local variable named 'ci' cannot be declared in this scope because it would give a different meaning to 'ci', which is already used in a 'parent or current' scope to denote something else

0

CheckedItems ci = ChkdItems.Where(ci => ci._id==id).Single(); -> CheckedItems ci = ChkdItems.Where(x => x._id==id).Single();

0

Dziękuje

1 użytkowników online, w tym zalogowanych: 0, gości: 1