How do I remove a specific item from a list?,How would I remove a specific item in a list?

I want to be able to remove the specific object that leaves the area, target.remove(target*) does not really solve my issue.*
private void OnTriggerExit(Collider collision)
{
int numTargs = target.Count;
for (int i = 0; i < numTargs; i++)
{
RaycastHit InRange;
Ray enterRay = new Ray(transform.position, -(transform.position - target*.transform.position));*
Debug.DrawRay(transform.position, -(transform.position - target*.transform.position));*
if (Physics.Raycast(enterRay, out InRange, sightRange))
{
if (InRange.collider)
{
target.
}
}
}
},I tried using target.remove(target*), which sort of works the way I want it to, but it will always remove the first item from the list, I want the object that leaves the area to be removed from the list instead.*
private void OnTriggerExit(Collider collision)
{
int numTargs = target.Count;
for (int i = 0; i < numTargs; i++)
{
RaycastHit InRange;
Ray enterRay = new Ray(transform.position, -(transform.position - target*.transform.position));*
Debug.DrawRay(transform.position, -(transform.position - target*.transform.position));*
if (Physics.Raycast(enterRay, out InRange, sightRange))
{
if (InRange.collider)
{
target.
}} } }

Removing from a list - Questions & Answers - Unity Discussions This might be helpful

If the targets leaving the area are triggering the OnTriggerExit event then you can do it without further raycasts using Linq with the following code:

private void OnTriggerExit(Collider collision)
{
        var targetIndex = target.IndexOf(t => t == collision.gameObject);
        if (targetIndex >= 0)
        {
            targets.RemoveAt(targetIndex);
        }
}

just make sure that you declare using System.Linq;