Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
CallBy Val Vs Ref Double
//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; using System.Diagnostics; namespace Rextester { public class Program { public static void Main(string[] args) { int aCount = 1000000; double aSum = 0; Stopwatch aWatch = Stopwatch.StartNew(); for(double i=0;i<aCount;i++) { aSum = CallByValue(i,i); } aWatch.Stop(); Console.WriteLine("Call By Value Took {0}",aWatch.Elapsed); aWatch.Start(); for(double i=0;i<aCount;i++) { CallByRef(ref i,ref i,ref aSum); } aWatch.Stop(); Console.WriteLine("Call By Ref Took {0}",aWatch.Elapsed); } public static double CallByValue(double one, double two) { return one+two; } public static void CallByRef(ref double one, ref double two,ref double theOut) { theOut = one+two; } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Print dulicate chars in a string
Robot_Testing
sum 2
Distinct of the given array with each element occurence
Exception-Nikhil
show IP
reverse linked list
StudentSysInput
Trading
T
stackse - search stackoverflow differently
Please log in to post a comment.