using System;
public class Program
{
public static void Main()
// https://www.youtube.com/watch?v=KSs5UR4jC1Q&ab_channel=ThePrimeTime&t=12m12s
// "Maybe we should start making it normal to do only read only" / ThePrimeagen
// Let us test that...
string message = "Hello World";
Method(message); // passed as immutable aka "const"/"let"
Console.WriteLine(message);
RefMethod(ref message); // passed as mutable aka by reference
// Conclusion: C# rocks! :)
}
// No worries, normal C# methods does not modify. It is the default to not affect what is provided.
public static void Method(string s)
s = "Won't be modified";
// You have to specifically specify that the passed is by reference, and is allowed to change.
public static void RefMethod(ref string s)
s = "Has been modified";