[Solved] I can’t figure out how to Return Values C# [closed]


All you have to do is this add this line after reading both lenght and depth values:

double total = compute(length, depth);

You’re telling that total will be what return from method compute.

Remember to send the parameters to method, and always call the method after you read both values, otherwise they’ll be zero when the method is called. You code should look like this:

static void Main(string[] args)
{
    double length = 0, depth = 0;

    Console.Write("What is the length in feet? ");
    length = Convert.ToDouble(Console.ReadLine());

    Console.Write("What is the depth in feet? ");
    depth = Convert.ToDouble(Console.ReadLine());

    double total = compute(length, depth);

    Console.WriteLine("${0}", total);
    Console.ReadKey();
}

solved I can’t figure out how to Return Values C# [closed]