Updated: October 2008
Returns a copy of this String converted to lowercase, using the casing rules of the current culture.
Namespace:
System
Assembly:
mscorlib (in mscorlib.dll)
Visual Basic (Declaration)
Public Function ToLower As String
Dim instance As String
Dim returnValue As String
returnValue = instance.ToLower()
public:
String^ ToLower()
public function ToLower() : String
This method takes into account the current culture. For more information, see the CultureInfo topic.
Note: |
|---|
This method does not modify the value of the current instance. Instead, it returns a new string in which all characters in the current instance are lowercased. |
Security Considerations
If you need the lowercase or uppercase version of an operating system identifier, such as a file name, named pipe, or registry key, use the ToLowerInvariant or ToUpperInvariant methods.
The following example converts several mixed case strings to lowercase.
Imports System
Public Class ToLowerTest
Public Shared Sub Main()
Dim info As String() = {"Name", "Title", "Age", "Location", "Gender"}
Console.WriteLine("The initial values in the array are:")
Dim s As String
For Each s In info
Console.WriteLine(s)
Next
Console.WriteLine("{0}The lowercase of these values is:", Environment.NewLine)
For Each s In info
Console.WriteLine(s.ToLower())
Next
Console.WriteLine("{0}The uppercase of these values is:", Environment.NewLine)
For Each s In info
Console.WriteLine(s.ToUpper())
Next
End Sub
End Class
' The example displays the following output:
' The initial values in the array are:
' Name
' Title
' Age
' Location
' Gender
'
' The lowercase of these values is:
' name
' title
' age
' location
' gender
'
' The uppercase of these values is:
' NAME
' TITLE
' AGE
' LOCATION
' GENDER
using System;
public class ToLowerTest {
public static void Main() {
string [] info = {"Name", "Title", "Age", "Location", "Gender"};
Console.WriteLine("The initial values in the array are:");
foreach (string s in info)
Console.WriteLine(s);
Console.WriteLine("{0}The lowercase of these values is:", Environment.NewLine);
foreach (string s in info)
Console.WriteLine(s.ToLower());
Console.WriteLine("{0}The uppercase of these values is:", Environment.NewLine);
foreach (string s in info)
Console.WriteLine(s.ToUpper());
}
}
// The example displays the following output:
// The initial values in the array are:
// Name
// Title
// Age
// Location
// Gender
//
// The lowercase of these values is:
// name
// title
// age
// location
// gender
//
// The uppercase of these values is:
// NAME
// TITLE
// AGE
// LOCATION
// GENDER
using namespace System;
using namespace System::Collections;
int main()
{
array<String^>^info = {"Name","Title","Age","Location","Gender"};
Console::WriteLine( "The initial values in the array are:" );
IEnumerator^ myEnum = info->GetEnumerator();
while ( myEnum->MoveNext() )
{
String^ s = safe_cast<String^>(myEnum->Current);
Console::WriteLine( s );
}
Console::WriteLine( " {0}The lowercase of these values is:", Environment::NewLine );
IEnumerator^ myEnum1 = info->GetEnumerator();
while ( myEnum1->MoveNext() )
{
String^ s = safe_cast<String^>(myEnum1->Current);
Console::WriteLine( s->ToLower() );
}
Console::WriteLine( " {0}The uppercase of these values is:", Environment::NewLine );
IEnumerator^ myEnum2 = info->GetEnumerator();
while ( myEnum2->MoveNext() )
{
String^ s = safe_cast<String^>(myEnum2->Current);
Console::WriteLine( s->ToUpper() );
}
}
// The example displays the following output:
// The initial values in the array are:
// Name
// Title
// Age
// Location
// Gender
//
// The lowercase of these values is:
// name
// title
// age
// location
// gender
//
// The uppercase of these values is:
// NAME
// TITLE
// AGE
// LOCATION
// GENDER
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
.NET Compact Framework
Supported in: 3.5, 2.0, 1.0
XNA Framework
Supported in: 3.0, 2.0, 1.0
Reference
Date | History | Reason |
|---|
October 2008
| Added a note that the method returns a new String object. |
Customer feedback.
|