How to change multiple Colliders at once

Hey I’m new here so this may seem like a stupid question but for about the pass few hours I’ve been stumped on it.

I have a game object (that is supposed to be a item that you can pick-up) with a few boxcolliders on it to give it physics. The problem is that I want to turn all the colliders off after the player picks it up but I haven’t been able to do that, can someone explain how to?

You can find all colliders (or any monobehaviour) on a gameObject using the “GetComponents<>()” function.

For instance:

public class MyItem : MonoBehaviour
{
	public void PickUp()
	{
		foreach (Collider2D collider in this.GetComponents<Collider2D>())
		{
			collider.enabled = false;
		}
	}
}

Thank you! I had to change this to the variable I wanted for it but other than that it was perfect!