Question : Pass String[] between classes?

Class2 returns string[] w/ data correctly, but Class1 remains an empty array.

[Class2]
private string[] userNames;

public string[] UserNames
{
      get { return userNames; }
}

[Class1]
string[] localArr = new string[0];
string[] class2Arr = Class2.UserNames;
Array.Copy(class2Arr, localArr, class2Arr.Length);

Answer : Pass String[] between classes?

public class class1
    {
        private string[] userNames;

        public string[] UserNames
        {
            get { return userNames; }
            set { userNames = value; }
        }
        public class1()
        {
            userNames = new string[1];
            userNames[0] = "pointeman";
        }

  public class class2
    {
        string[] local = null;
        public class2()
        {
            class1 c = new class1();
            local = new string[c.UserNames.Length];
            c.UserNames.CopyTo(local, 0);
        }
     
    }
Random Solutions  
 
programming4us programming4us