I am overwriting the variables 'arr [1]' and 'test' in the setValues () function.
arr [1] changed to "BBB"
but the test will not change to '222'
Output: BBB111
but he must be BBB222
Why is the test line not updated?
public class Program
{
static void Main(string[] args)
{
string[] arr = new string[10];
arr[1] = "AAA";
string test = "111";
setValues(arr, test);
int exit = -1;
while (exit < 0)
{
for (int i = 0; i < arr.Length; i++)
{
if (!String.IsNullOrEmpty(arr[i]))
{
Console.WriteLine(arr[i] + test);
}
}
}
}
private static void setValues(string[] arr, string test)
{
arr[1] = "BBB";
test = "222";
}
}
source
share