/ Published in: C#
In Delphi you have the possibility to modify Methods' Parameters (e.g. procedure AddPlus(var number: integer);) - in C# you will find the following realm of possibility:
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
using System; namespace parameters { public static class democlass { //normal use public static int Add(int left, int right) { return left + right; } //use the ref Parameter, e.g. for increment public static void AddPlus(ref int number) { number = number + 1; } //use the out Parameter public static void GetHundred(out int number) { number = 100; } } class Program { static void Main(string[] args) { int a = 10; int b = 20; int c; c = democlass.Add(a, b); Console.WriteLine(c); //30 democlass.AddPlus(ref c); Console.WriteLine(c); //31 democlass.GetHundred(out c); Console.WriteLine(c); //100 } } }