introductory-examples/functions/fragmented/simple-function-demo.cs - Demonstration of simple functions in C#. | Lecture 2 - slide 15 : 43 Program 1 |
/* Right, Wrong */ using System; /* public int Increment(int i){ return i + 1; } public void Main (){ int i = 5, j = Increment(i); Console.WriteLine("i and j: {0}, {1}", i, j); } // end Main */ public class FunctionDemo { public static void Main (){ SimpleFunction(); } public static void SimpleFunction(){ int i = 5, j = Increment(i); Console.WriteLine("i and j: {0}, {1}", i, j); } public static int Increment(int i){ return i + 1; } }