How to assign an int to object in a for loop

So I’m having some trouble with the resolutions options in my game, Unity for some reason shows a bunch of weird refresh rates if I have all the “Screen.resolutions;” available. To fix that I decided to detect if they are different from 60,120 and 144hz refresh rates, if so they are excluded from the options.
Everything fine until that point, but as we reduce the options of resolutions, I would have to assign each resolution an Index and check for that index when setting the resolution, I have no idea how to do that.

What I have for now:

 List<string> options = new List<string>();

        int currentResIndex = 0;
            
        for (int i = 0; i < resolutions.Length; i++)
        {
            resIndex++; //The idea here is to add an Index to every resolution, even the unused ones, so we can skip them in the function that sets the resolution.
                        //But I know that all this is doing for now is getting the total number of resolutions(in int form), and not assigning an Index for each of them. Idk how to do that

            string option = resolutions<em>.width + " x " + resolutions_.height + " " + resolutions*.refreshRate +"Hz";*_</em>

if (resolutions.refreshRate == 59 || resolutions_.refreshRate == 119 || resolutions*.refreshRate == 144) {*
options.Add(option);_

}
if (resolutions.width == Screen.currentResolution.width && resolutions_.height == Screen.currentResolution.height && resolutions*.refreshRate == Screen.currentResolution.refreshRate)
{
currentResIndex = i;
}
}*_

resDropdown.AddOptions(options);

}

///(…)

public void SetResolution(int thisResIndex) {
thisResIndex = resIndex; //Here we would retrieve the assigned index for the resolution and set the resolution according to it.
Resolution resolution = resolutions[thisResIndex];
Screen.SetResolution(resolution.width, resolution.height, Screen.fullScreen);
print(resolution.width + resolution.height);
}

Assuming I understand your issue correctly, you could use Linq to filter the resolutions list for only those resolutions with reasonable refresh rates (or any other constraint you want):

For example:

public IEnumerable<Resolution> GetReasonableScreenResolutions () {
    return new List<Resolution> (Screen.resolutions)
        // Filter out all resolutions that don't have a "supported" refresh rate
        .Where (HasReasonableRefreshRate)
        // Combine all resolutions that share a width and height
        .GroupBy (resolution => (resolution.width, resolution.height))
        .Select (group => group.First ())
        // Example: throw out all resolutions that are not 16:9
        .Where (resolution => HasAspectRatio (resolution, 16f / 9f));
}

public bool HasReasonableRefreshRate (Resolution resolution) {
    return resolution.refreshRate == 60 ||
           resolution.refreshRate == 120 || 
           resolution.refreshRate == 144;
}

public bool HasAspectRatio (Resolution resolution, float desiredAspect) {
    return Mathf.Approximately ((float) resolution.width / resolution.height, desiredAspect);
}

One thing you can do is try the opposite approach. Basically have a list of all the resolutions and only remove the ones you don’t need.

It would be something like this:

for(int i =0; i < AllResolutionsList.Count;i++){
if(AllResolutionsList*.isInCompatible()){*

AllResolutionsList.RemoveAt(i);
//We reduce i once since we removed an element and we wanna go back once
i–;
}
}
Where isIncompatible is a bool function that returns true if it’s a resolution you don’t want to include. The above result will reduce the list so that it will only include the resolutions you want.