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

后端 未结 4 694
臣服心动
臣服心动 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:40

    you can construct a new list from your original one :

    var newList = lineArray.Select(x => x == "(null)" ? "NULL" : string.Format("'{0}'", x));
    

提交回复
热议问题