I have this:
var lineArray = line.Split(\';\');
lineArray.ToList().ForEach(x =>
{
if (x == \"(null)\")
x = \"NULL\";
else
x = string.
I think this small change will work
var lineArray = line.Split(';').ToList();
lineArray.ForEach(x =>
{
if (x == "(null)")
x = "NULL";
else
x = string.Format("'{0}'", x);
});
Below is a working example
string line = "a;b;null;c;";
var lineArray = line.Split(';').ToList();
lineArray.ForEach(x =>
{
if (x == "(null)")
x = "NULL";
else
x = string.Format("'{0}'", x);
});
Result:
If you need just to remove (null) values from the list, you do not need to loop just use removeAll
lineArray.RemoveAll(a=>a.Equals("(null)"));
working example below