Double, reference parameters - Practice Exercises C# Sharp Lesson 5: Functions Exercise 5.9: Double, reference parameters Objetive: Create a function named "Double" to calculate the double of an integer number, and modify the data passed as an argument. It must be a "void" function and you must use "refererence parameters". For example. x = 5; Double(ref x); Console.Write(x); would display 10 Source Code: C# JAVA using System; public class F_DoubleRef { public static void Double(ref int n) { n = n + n; } public static void Main() { int x = 2; Double(ref x); Console.WriteLine(x); } } Copy Exercise to ClipBoard Copy Code to ClipBoard Exercisey 5.9
More exercises for Lesson 5 Previous Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 Next >>