Pass value out of a method - CSharp Custom Type

CSharp examples for Custom Type:Method Parameter

Description

Pass value out of a method

Demo Code

using System;/*from  w w w  .  j  a va2  s .co  m*/
class Program
{
   static void Main(string[] args)
   {
      int a = 8;
      int b = 2;
      int sum, diff, prod;
      doEverything(a, b, out sum, out diff, out prod);
      Console.WriteLine("Sum: {0}", sum);
      Console.WriteLine("Diff: {0}", diff);
      Console.WriteLine("Product: {0}", prod);
      Console.ReadKey();
   }
   static void doEverything(int a, int b, out int sum, out int diff, out int prod)
   {
      sum = a + b;
      diff = a - b;
      prod = a * b;
   }
}

Result


Related Tutorials