Использование метода List.Contains
This commit is contained in:
parent
8dd8105e4d
commit
86f03f05c5
@ -28,13 +28,10 @@
|
||||
/// <returns></returns>
|
||||
public int Insert(T locomotive)
|
||||
{
|
||||
for (int i = 0; i < _places.Count; i++)
|
||||
{
|
||||
if (locomotive.Equals(_places[i]))
|
||||
if (_places.Contains(locomotive))
|
||||
{
|
||||
throw new NotUniqueObjectException();
|
||||
}
|
||||
}
|
||||
if (_places.Count == 0)
|
||||
{
|
||||
_places.Add(locomotive);
|
||||
|
Loading…
Reference in New Issue
Block a user