Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
ref variables/parameters
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { static void changeValue(ref int n) // directly access the memory location of passed variable as parameter n with 'ref' keyword { n = n * n; // value of variable 'a' in Main method updated directly, hence it doesn't need to be returned } public static void Main(string[] args) { int a; a=10; changeValue(ref a); // pass memory location (address) of variable a using 'ref' keyword //notice that the changeValue() return type is void, but still it affects the original variable's value Console.WriteLine("After changes : " + a); } } }
run
|
edit
|
history
|
help
0
test string format with curly braces as a value
sum of two array elements
unix practice - santhosh
HTML Hex to RGB without using System.Drawing C#
Custom Date Format
Fórum Parallel Threads ( With Much Fun )
Const
to find the first index of a substring in a given string
наименьшее общее кратное двух чисел a и b
Prime number