how to check if a collider is colliding unity code example

Example: unity check if position is inside collider

//For 3D :
public Collider[] colliders;
public Vector3 yourPosition;
     
     private void CheckPositionInsideCollider()
     {
       colliders = Physics.OverlapSphere(yourPosition, 0.0f);
       return colliders; //returns all the colliders that contain your position
     }

//For 2D :
public Collider2D[] colliders;
public Vector2 yourPosition;
     
     private void CheckPositionInsideCollider()
     {
       colliders = Physics2D.OverlapCircleAll(yourPosition, 0.0f);
       return colliders;
     }