c# pass arg by reference
void Method(ref int refArgument)
{
// Second param will add to int refArgument
refArgument = refArgument + 44;
}
int number = 1;
Method(ref number);
Console.WriteLine(number);
// Output: 45
c# pass arg by reference
void Method(ref int refArgument)
{
// Second param will add to int refArgument
refArgument = refArgument + 44;
}
int number = 1;
Method(ref number);
Console.WriteLine(number);
// Output: 45
c# ref
void Method(ref int refArgument)
{
refArgument = refArgument + 44;
}
int number = 1;
Method(ref number);
Console.WriteLine(number);
// Output: 45
by value by reference c#
static void squareRef(ref int refParameter)
{
refParameter *= refParameter;
}
cannot initialize a by-value variable with a reference
// must declare variable as ref as well!
ref int x = ref SomeClass.variable;
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us