Tag: ref
Pass by Reference using ref keyword
You can use the keyword ref in csharp to pass a value by reference instead of call by value . using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Namespace1 { class Student { public string StudentName { get; set; } /* usage of the pass by reference using the keyword ref */ public void Add(ref int i) { i = i +…
out keyword in c#
You can use the keyword out in c# to pass the arguments by reference . The out keyword works almost the same as ref keyword but one of the difference between the out and ref keyword is that out doesn’t require the variable to be initialized where as the ref keyword requires that the variable be initialized before passing it to the function. Below is…