Is there any way to do this, assign a value within a List.ForEach() statement?

后端 未结 4 692
臣服心动
臣服心动 2021-01-22 22:08

I have this:

var lineArray = line.Split(\';\');

lineArray.ToList().ForEach(x =>
{
    if (x == \"(null)\")
        x = \"NULL\";
    else
        x = string.         


        
4条回答
  •  鱼传尺愫
    2021-01-22 22:51

    don't use ForEach like that - use a for loop.

    for (int i = 0; i < lineArray.Length; i++)
    {
        if (lineArray[i] == "(null)")
            lineArray[i] = "NULL";
        else
            lineArray[i] = string.Format("'{0}'", lineArray[i]);
    }
    

提交回复
热议问题