Say I have the below example, the syntax is based off constuctor chaining for clarity (and my cluelessness).

    public static void Feed() : this("Unknown"){}

    public static void Feed(string FoodType)
    {
        if (Food != "Unknown")
            Console.WriteLine("{0} eats some {1}.", Name, Food);
    }

How would I actually implement this for methods? It is of the same style as constructor chaining, that if nothing is passed to the Feed method it will pass Unknown to the latter Feed method.

Such a simple question but its bugging me lol.

If Feed is a method, it would look something like this:

public void Feed(string FoodType)
{
    if (Food != "Unknown")
        Console.WriteLine("{0} eats some {1}.", Name, Food);
}

public void Feed()
{
    Feed("Unknown");
}

If you're using .net 4.0 or later you can create default values for your parameters

public static void Feed(string Food="Unknown")
{
    if (Food != "Unknown")
    Console.WriteLine("{0} eats some {1}.", Name, Food);
}

Edited 4 Years Ago by nakor77: modified default value

This question has already been answered. Start a new discussion instead.