if from an array like this one
string[] arr={"a", "b"};
Can i modify it in this way?
arr={"a"};
CodePudding user response:
You can do it in the following different ways:
1)
var idx = 1;
arr = arr.Where((s, i) => i != idx).ToArray();
arr = arr.Where(s => s != "b").ToArray();
var filter = {"b"};
arr = arr.Except(filter);
CodePudding user response:
try this
arr = new string[] { arr[0] };