C#C
C#3y ago
Zee

❔ is there a way for a method to have interchangeable parameter?

is there a way for a method to have interchangeable parameter depending on when I call it?

so I have this method
       public void DrankHealthBoost(Health_Boost potion)
        {
            health += 1;
        }

this method has a parameter of type Health_Boost and when I call it I do this

    private void CollectHealthPot(Health_Boost potion, Player pl)
        {
            pl.DrankHealthBoost(potion);

        }

is there a way I can change the DrankHealthBoost(Health_Boost potion) parameter so I can do something like this

        private void CollectHealthPot(Shop potion, Player pl)
        {
            pl.DrankHealthBoost(potion);

        }


so have the parameter to be of type class shop
Was this page helpful?