CSharp examples for Custom Type:Method Parameter
Using out Access to Parameters
using System;//from w w w. ja v a 2s. c o m class nbr { public void math_routines(double x, out double half, out double squared, out double cubed) { half = x / 2; cubed = x * x * x; squared = x * x; } } class TestApp { public static void Main() { nbr doit = new nbr(); double nbr = 600; double Half_nbr = 0; double Squared_nbr = 0; double Cubed_nbr = 0; Console.WriteLine("Before method -> nbr = {0}", nbr); Console.WriteLine(" Half_nbr = {0}", Half_nbr); Console.WriteLine(" Squared_nbr = {0}", Squared_nbr); Console.WriteLine(" Cubed_nbr = {0}\n", Cubed_nbr); doit.math_routines(nbr, out Half_nbr, out Squared_nbr, out Cubed_nbr); Console.WriteLine("After method -> nbr = {0}", nbr); Console.WriteLine(" Half_nbr = {0}", Half_nbr); Console.WriteLine(" Squared_nbr = {0}", Squared_nbr); Console.WriteLine(" Cubed_nbr = {0}", Cubed_nbr); } }