[Solved] How to access a generic class method inside another class by index or some better way?

Gabriel Asks: How to access a generic class method inside another class by index or some better way?
What I want is to “dynamically” access a method of a generic class inside a class by index or by some better way. “Dynamically” because there will not only be two generic classes inside this main class, so I want an easy way to access the methods of the generic classes, because it would be exhausting to keep calling all the methods all the time. This is the class and what I already tried:

Code:
public class ListOfPowerClass
{
    public PowerClass<SomePowerClassOne> PowerOne = new PowerClass<SomePowerClassOne>(new SomePowerClassOne(), false);
    public PowerClass<SomePowerClassTwo> PowerTwo = new PowerClass<SomePowerClassTwo>(new SomePowerClassTwo(), false);    

    public class PowerClass<T> where T : class 
    {
            public bool I_Have;
            public T Power;      

            public PowerClass(T _Power, bool _Active)
            {
                Power = _Power;
                Active = _Active;
            }
    } 
}

This is the methods inside each class.

Code:
public class SomePowerClassOne
{
    public void Print()
    {
        Console.WriteLine("This is the power one");
    }
}

public class SomePowerClassTwo
{
    public void Print()
    {
        Console.WriteLine("This is the power two");
    }
}

And this is what I want to do:

Code:
public int index; //This index will change and I will access different classes.
public ListOfPowerClass PowerList = new ListOfPowerClass();
PowerList[index].Print(); ///index = 0, I will access class PowerOne 
PowerList[index].Print(); ///index = 1, I will access class PowerTwo
PowerList[index].Print(); ///index = 2, I will access class PowerThree and so on

I googled and found out about Indexers ([int index]), but I don’t now why I can’t apply to the “ListOfPowerClass” Class or any of your methods like below, because It’s just throw a sintax error.:

Code:
public class ListOfPowerClass [int index]
public T ReturnClass<T>(int index) [int index]
public class PowerClass<T> where T : class [int index]

And I also found about reflection, but I honestly don’t understant anything that I read and I don’t know how to make it work with my code.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.