📜  C# tolow all in a array - C# (1)

📅  最后修改于: 2023-12-03 14:39:44.351000             🧑  作者: Mango

C# toLower All in an Array

Sometimes, as a programmer, you may need to convert all the strings in an array to lowercase. This task can easily be accomplished in C# using the ToLower() method in a loop.

Implementation

Here is an example code that demonstrates how to convert all strings in an array to lowercase:

string[] words = { "HELLO", "WORLD", "!" };

for (int i = 0; i < words.Length; i++)
{
    words[i] = words[i].ToLower();
}

In this code, we first create an array of strings called words. We then loop through each element in the array using a for loop, and call the ToLower() method on each string.

After the loop is finished, all the strings in the array will have been converted to lowercase.

Conclusion

Converting all the strings in an array to lowercase is a common task that can be done easily in C#. By using the ToLower() method in a loop, we can quickly and efficiently perform this operation.