I have string array string[] MyArray
. What is the quickest (meaning least code, not fastest performance) way to convert all string array elements to lowercase?
To convert all array elements to lowercase:Use the map() method to iterate over the array. On each iteration, call the toLowerCase() method to convert the string to lowercase and return the result. The map method will return a new array containing only lowercase strings.
toLowerCase(). split(",");
Java String toLowerCase() Method The toLowerCase() method converts a string to lower case letters. Note: The toUpperCase() method converts a string to upper case letters.
var MyArrayLower = MyArray.Select(s => s.ToLowerInvariant()).ToArray();
(or
MyArray = MyArray.Select(s => s.ToLowerInvariant()).ToArray();
if you want to replace the existing array with a new instance of string[]
.)
Easiest approach:
MyArray = Array.ConvertAll(MyArray, d => d.ToLower());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With