Reputation: 5343
Controls is collection of clsname. To remove setter warnings wee removed set; from the property. So we need to add items one by one to it.
public Collection<clsname> Controls
{
get
{
return _controls;
}
}
Collection<clsName> _controls= new Collection<clsName>();
foreach(UIControl z in _view.Controls)
{
_controls.Add(z);
}
if i assign items one by using .Add() below condition always retuns false. when i check each items from both the object it returns true but as a collection object it fails.
if (controls.Controls == _view.Controls)
{
}
Upvotes: 1
Views: 50
Reputation: 726599
Collection<T>
does not override ==
for item-by-item comparison, so you need to check the equality yourself. If the sequence is important, use LINQ's SequenceEqual
:
if (controls.Controls.SequenceEqual(_view.Controls)) {
...
}
Upvotes: 2