Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use multiple methods in C#?
#6
SaptaZapta Wrote:Seems to me that before you can learn to write methods, you should learn to write C functions.

That's what I'd like to know, because the above concepts are so pointlessly unrelated as to seem to be confusing what he's trying to do.

It really sounds like the requirements as simple as:

Code:
void main()
{
    int x, y, prod, s, diff;

    string inputValue;

    Console.WriteLine("Enter the first number: ");
    inputValue = Console.ReadLine();
    x = int.Parse(inputValue);
    Console.WriteLine("Please enter the second number: ");
    inputValue = Console.ReadLine();
    y = int.Parse(inputValue);

    prod = product( x, y);
    s = sum( x,y);
    diff = difference( x,y);

/*
    Do whatever with values.
*/
    return;
}

int sum( int x, int y )
{
    return x+y;
}

int product( int x, int y )
{
    return x*y;
}

int difference( int x, int y )
{
    return x-y;
}

And then applying that logic to classes and methods. But generally you'd learn that bit first, not as a secondary concept. :f6:
It's not having what you want - It's wanting what you've got.
Reply


Messages In This Thread
How to use multiple methods in C#? - by Eos - 2012-03-31, 11:36 PM
How to use multiple methods in C#? - by Eos - 2012-04-01, 12:33 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)