I would like to skip the remainder of a function and call another should a statement prove true.

public bool A(int i)
        {
            if (i > 5)
            {
                // Skip the rest of A() and return B()
                return B(i);
            }

            // Do stuff to i
        }

        public bool B(int i)
        {
            // Do stuff to i
        }

Is my only option to have the return value as a bool, even if I don't care what the boolean return value is?

This is for when not wanting it to return anything. Notice that when returning nothing, it will just exit out of the method.

public void A(int i)
        {
            if (i > 5)
            {
                // Skip the rest of A() and return B()
                B(i);
                return;
            }

            // Do stuff to i
        }

        public void B(int i)
        {
            // Do stuff to i
        }

Thank you. :)

Does this have any speed advtanges over returning bool?

Not really. You only want to use bool or anything returned if you will be doing logic on it later.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.