Domanda

for (int z = 0; z < alParmValues.Count; z++)
{
    asd.Add((alParmValues[z].ToString().Split(',')));// asd is list<string> 
    def.Add(alMethSign[z].ToString().Substring(alMethSign[z].ToString().IndexOf('(') + 1, alMethSign[z].ToString().IndexOf(')') - (alMethSign[z].ToString().IndexOf('(') + 1)).Split(','));// def is list<string>
}

Questi sono gli errori che ottengo quando compilo:

Error 7  The best overloaded method match for 'System.Collections.Generic.List<string>.Add(string)' has some invalid arguments
    D:\HUTT\Code\HUTT\NUnitClasses\BaseGenerator.cs 1118    18  HUTT   
Error 8  Argument '1': cannot convert from 'string[]' to 'string'
    D:\HUTT\Code\HUTT\NUnitClasses\BaseGenerator.cs 1118    27  HUTT
È stato utile?

Soluzione

Il compilatore ti sta dicendo che non puoi usare il metodo List.Add () che prevede una stringa come input, perché lo stai restituendo Split () che restituisce una stringa [] . Per usare una stringa [] come input, usa AddRange () .

Altri suggerimenti

Usa AddRange invece di Aggiungi.

Prova addrange

String.Split restituisce una matrice di stringhe (stringa []) ma List.Add prevede un parametro di tipo stringa.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top