Full Example

CSharp · Console

/Program.cs

using System;
					
public class Program
{
	public static void Main()
	{
		ExampleOne();
		
		ExampleTwo();
	}
	
	public static string MyRefMethod(ref string str)
	{
		str = "new value";
		return "this variable doesn't really matter for this example";
	}
	
	public static void MyMethodForExampleOne(string importantString, string doesntMatterString)
	{
		Console.WriteLine(importantString);
	}
	
	public static void MyMethodForExampleTwo(string doesntMatterString,string importantString)
	{
		Console.WriteLine(importantString);
	}
	
	public static void ExampleOne()
	{
		Console.WriteLine("---------EXAMPLE ONE----------");
		
		var myString = "initial value";
		
		MyMethodForExampleOne(myString, MyRefMethod(ref myString));
	}
	
	
	public static void ExampleTwo()
	{
		Console.WriteLine("---------EXAMPLE TWO----------");
		var myString = "initial value";
		
		MyMethodForExampleTwo(MyRefMethod(ref myString),myString);
	}
	
}
;