Корректирование проверок позиции
This commit is contained in:
parent
1f69ad5765
commit
40f345bcb8
@ -56,7 +56,7 @@ namespace AntiAircraftGun
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int Insert(T antiAircraftGun, int position)
|
public int Insert(T antiAircraftGun, int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position > _places.Count) return -1;
|
if (position < 0 || position >= _places.Count) return -1;
|
||||||
_places.Insert(position, antiAircraftGun);
|
_places.Insert(position, antiAircraftGun);
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ namespace AntiAircraftGun
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public T Remove(int position)
|
public T Remove(int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position > _places.Count) return null;
|
if (position < 0 || position >= _places.Count) return null;
|
||||||
if (_places[position] == null) return null;
|
if (_places[position] == null) return null;
|
||||||
T removed = _places[position];
|
T removed = _places[position];
|
||||||
_places.RemoveAt(position);
|
_places.RemoveAt(position);
|
||||||
@ -82,12 +82,12 @@ namespace AntiAircraftGun
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (position < 0 || position > _places.Count) return null;
|
if (position < 0 || position >= _places.Count) return null;
|
||||||
return _places[position];
|
return _places[position];
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (position < 0 || position > _places.Count) return;
|
if (position < 0 || position >= _places.Count) return;
|
||||||
_places.Insert(position, value);
|
_places.Insert(position, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user