views:

148

answers:

4
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>
}

These are the errors I get when I compile:

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
+4  A: 

Use AddRange instead of Add.

Dustin Campbell
+5  A: 

The compiler is telling you, that you cannot use the List.Add() method that expects a string as input, because you're handing it the return of Split() which returns a string[]. To use a string[] as input, use AddRange().

Brian Rasmussen
+2  A: 

Try addrange

Julian de Wit
A: 

String.Split returns an array of strings (string[]) but List.Add expects a parameter of type string.

Jakob Christensen