Page 1 of 1

Auslassen des Schlüsselworts in Parameter

Posted: 06 Apr 2025, 21:33
by Anonymous
Ich habe den folgenden C# -Code, in dem ich versuche, das Verhalten des In -Parameter -Modifikators zu verstehen.

Code: Select all

public static void Main(string[] args)
{
int i = 0;
int j = 0;
InParameterTest(i,() => i++);
InParameterTest(in j, () => j++);
}

private static void InParameterTest(in int number, Action action)
{
action();
Console.WriteLine(number);
}
< /code>
Ausgabe: < /p>
1
1