In Monogame/XNA in C#, detecting if two instances have intersected and returning those two

Hi. I’ve been stuck at a dead end for a bit and it’s slowing down my progress at a halt. You see, I have a class called Pet.cs
And in the main class Game1.cs, I have a list of pet classes called Pets.
I added three pets. In Pet.cs, there’s a rectangle called petbounds, meant to be a hitbox so each Pet.cs will have it. They all exist and have the right size and position, I’ve confirmed this to be true. However, I am seeking a way to check if a pet runs into another pet.
I can’t just write in Game1.cs:

for (int i = 0; i < Pets.Count; i++)

{

if (Pets[i].petbounds.Intersects(Pets[i].petbounds))

 {

   //fight or whatever lol

  }

}

That’s not gonna work. Right away, it’s just gonna intersect with itself. At least that’s what I’m presuming, seeing that the if statement becomes true immediately when only one pet is created and there’s not 2 or 3.
How can I construct an if statement or solution to make it that “If pet collides with ANY other pet except for itself”

   for (int c = 0; c < Pets.Count; c++)
                for (int i = 0; i < Pets.Count; i++)
                   if (i != c && Pets[c].petbounds.Intersects(Pets[i].petbounds))
                    {
                    //fight or whatever lol
                    }

You need to loop through it twice. If c == I its the same pet so you can skip the check

Its worth noting that the above solution is looping through much, much more than twice, because you loop through all of the pets once for every single pet that exists.

There are of course optimizations that can be made - assuming Pets[c].bounds.Intersets(Pets[i].petbounds) is the same as Pets[i].bounds.Intersects(Pets[c].petbounds) - you can change the above implementation so that i is strictly greater than c, which will prevent comparisons being made a second time.

This solution is fine for many kinds of games, but you may want to look into something like Quad Trees for a more performant solution.