Interfaces define a contract.

public interface IDamageable
{
    void TakeDamage(int amount);
}

Implementation:

public class Enemy :
    MonoBehaviour,
    IDamageable
{
    public void TakeDamage(int amount)
    {
    }
}

Generic interaction:

if (hit.collider.TryGetComponent<IDamageable>(
    out IDamageable target))
{
    target.TakeDamage(25);
}