How to implement the code in which the object will trigger only objec tagged with "X"

How to implement the code in which the object will trigger only objec tagged with “X”. Sorry from my English, im from Russia.

something like this?

public class example : MonoBehaviour
        {
            void OnTriggerEnter(Collider other)
            {
                if(other.tag == "X")
                    Destroy(other.gameObject);
            }
        }