The ref local keyword allows you to store references in a local variable by declaring local variables with the ref keyword and add the ref keyword before a method call or assignment. For example, in the following code, the day string variable references dayOfWeek; changing the value of day also changes the value of dayOfWeek and vice versa:
string dayOfWeek = "Sunday";ref string day = ref dayOfWeek;Console.WriteLine($"day-{day}, dayOfWeek-{dayOfWeek}");day = "Monday";Console.WriteLine($"day-{day}, dayOfWeek-{dayOfWeek}");dayOfWeek = "Tuesday";Console.WriteLine($"day-{day}, dayOfWeek-{dayOfWeek}");-----------------Output:day: SundaydayOfWeek: Sundayday: MondaydayOfWeek: Mondayday: TuesdaydayOfWeek: Tuesday