How do i get script variables from a prefab inside a list?

Hi everyone. Basically, i got a script that renderize some prefabs. They’re all stored inside a List (the one from System.Collections.Generic) and all of 'em got another script. I want at some point do something like analyze a variable inside all of the prefabs stored inside the list (all of them have the same script). The problem is that i don’t know how to get variables from a script of an object if there are lots of those objects in the scene at runtime. I searched around for a while but all of the documentation looks like to be meant for a specific object use (not for a list of objects stored in a list).
I explain better: in code terms, what i’d like to do is something like:

for(int i = 0; i < list.Count; i++)
    if(list*.variable == 1) //well that .variable is how i'd do my purpose in other languages like java where you just have to import the name of the script from the bottom, declare an instance and then use it.*

sorry for the very noob question.
regard and many thanks in advance.

The code you have looks fine to me. Did you try it already, and what seems to be your problem?

All you need to do is:


if the script in the list has its own DoSomething function,
DoSomething (list*.gameObject);*
if DoSomething is a function on your main script that takes a GameObject as an argument.