C#C
C#2y ago
傑夫

Class Objects Aren't Working Correctly?

Doesn't seem like anything is appending to the arrays. When i call it in the mainform. it doesn't pull anything. am i missing anything here?


My Auth Class Code Snippet from its Constructor
VPNInfo[] avpns     = new VPNInfo[] { };
this.raw_vpns       = new string[] { };
int i               = 0;

foreach (string line in vpns)
{
    if (line.Contains("db.VPN{"))
    {
        string name = vpns[i + 1].Replace("name:", "").Replace("'", "").Trim();
        string ip = vpns[i + 2].Replace("ip:", "").Replace("'", "").Trim();
        string config = vpns[i + 3].Replace("config:", "").Replace("'", "").Trim();
        string access_lvl = vpns[i + 4].Replace("access_level:", "").Replace("'", "").Trim();
        VPNInfo vpn = new VPNInfo(name, ip, config, access_lvl);
        avpns.Append(vpn);
        this.raw_vpns.Append(name);
        MessageBox.Show(name); // DEBUGGING CODE
    }
    i++;
}


Main Form code snippet

foreach(VPNInfo vpn in this.CS.User.available_vpns)
{
    listBox1.Items.Add($"{vpn.name} | {vpn.ip}");
}
Was this page helpful?