Is there a function to remove the last cell from array?
it's a string array like: {"a","b","c",""}.
Is there a function to remove the last cell from array?
it's a string array like: {"a","b","c",""}.
If it's an array of strings, you can do something like:
string[] results = theArray.Where(s => !string.IsNullOrWhitespace(s)).ToArray();
If you are just going to iterate the results, there's no need to convert back into an array, and you can leave off the .ToArray() at the end.
Edit:
If you just want to remove the last cell, and not empty entries (as suggested by your edited version), you can do this using Array.Copy more efficiently than using the LINQ statement above:
string[] results = new string[theArray.Length - 1];
Array.Copy( theArray, results, results.Length );