Split - Index was outside the bounds of the array

后端 未结 7 564
野性不改
野性不改 2020-12-18 04:25

Im using the following code to split up a string and store it:

string[] proxyAdrs = linesProxy[i].Split(\':\');
string proxyServer = proxyAdrs[0];
int proxyP         


        
7条回答
  •  不思量自难忘°
    2020-12-18 05:07

    Try this:

            string[] proxyAdrs = linesProxy[i].Split(':');
            string proxyServer = proxyAdrs[0];
            int proxyPort = Convert.ToInt32(proxyAdrs[1]);
    
    
            if(proxyAdrs.Length > 2 && proxyAdrs[2] != null)
            {
                item.Username = proxyAdrs[2];
            }
    
            if (proxyAdrs.Length > 3 && proxyAdrs[3] != null)
            {
                item.Password = proxyAdrs[3];
            }
    

提交回复
热议问题