String.ToLower 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
이 문자열의 복사본을 소문자로 변환하여 반환합니다.
오버로드
ToLower() |
이 문자열의 복사본을 소문자로 변환하여 반환합니다. |
ToLower(CultureInfo) |
지정한 문화권의 대/소문자 규칙을 사용하여 소문자로 변환된 이 문자열의 복사본을 반환합니다. |
ToLower()
이 문자열의 복사본을 소문자로 변환하여 반환합니다.
public:
System::String ^ ToLower();
public string ToLower ();
member this.ToLower : unit -> string
Public Function ToLower () As String
반환
소문자 문자열입니다.
예제
다음 예에서는 여러 개의 혼합 된 case 문자열을 소문자로 변환 합니다.
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
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
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
설명
이 메서드는 현재 문화권의 대/소문자 규칙을 고려 합니다.
참고
이 메서드는 현재 인스턴스의 값을 수정 하지 않습니다. 대신 현재 인스턴스의 모든 문자가 소문자로 변환 된 새 문자열을 반환 합니다.
보안 고려사항
메서드를 호출한 결과로 발생 하는 대/소문자 구분 연산은 ToLower() 현재 문화권의 대/소문자 규칙을 고려 합니다. 파일 이름, 명명 된 파이프 또는 레지스트리 키와 같은 운영 체제 식별자의 소문자 또는 대문자 버전이 필요한 경우 ToLowerInvariant 또는 메서드를 사용 ToUpperInvariant 합니다. 이는 메서드와 달리 모든 문화권에서 동일한 결과를 생성 ToLower() 하 고 더 효율적으로 수행 합니다.
호출자 참고
문자열 사용에 대 한 모범 사례에서 설명 했 듯이 기본값을 대체 하는 문자열 대/소문자 메서드를 호출 하는 대신 매개 변수를 명시적으로 지정 해야 하는 메서드를 호출 하는 것이 좋습니다. 현재 문화권의 대/소문자 규칙을 사용 하 여 문자를 소문자로 변환 하려면 ToLower(CultureInfo) 매개 변수의 값을 사용 하 여 메서드 오버 로드를 호출 합니다 CurrentCulture culture
.
추가 정보
적용 대상
ToLower(CultureInfo)
지정한 문화권의 대/소문자 규칙을 사용하여 소문자로 변환된 이 문자열의 복사본을 반환합니다.
public:
System::String ^ ToLower(System::Globalization::CultureInfo ^ culture);
public string ToLower (System.Globalization.CultureInfo? culture);
public string ToLower (System.Globalization.CultureInfo culture);
member this.ToLower : System.Globalization.CultureInfo -> string
Public Function ToLower (culture As CultureInfo) As String
매개 변수
- culture
- CultureInfo
문화권별 대/소문자 규칙을 제공하는 개체입니다. culture
가 null
이면 현재 문화권이 사용됩니다.
반환
소문자로 표시된 현재 문자열입니다.
예제
다음 예에서는 English-United 상태 및 Turkish-Turkey 문화권을 사용 하 여 대문자의 두 문자열을 소문자로 변환한 다음 소문자 문자열을 비교 합니다. 대문자 문자열은 한 문자열에서 각 유니코드 라틴어 대문자 i가 발생 하는 경우를 제외 하 고는 동일 합니다. 다른 문자열에는 위의 점이 있는 라틴어 대문자 I가 포함 됩니다.
// Sample for String::ToLower(CultureInfo)
using namespace System;
using namespace System::Globalization;
void CodePoints( String^ title, String^ s )
{
Console::Write( "{0}The code points in {1} are: {0}", Environment::NewLine, title );
System::Collections::IEnumerator^ myEnum = s->GetEnumerator();
while ( myEnum->MoveNext() )
{
UInt16 u = safe_cast<Char>(myEnum->Current);
Console::Write( "{0:x4} ", u );
}
Console::WriteLine();
}
int main()
{
String^ str1 = "INDIGO";
// str2 = str1, except each 'I' is '\u0130' (Unicode LATIN CAPITAL I WITH DOT ABOVE).
array<Char>^temp = {L'\u0130',L'N',L'D',L'\u0130',L'G',L'O'};
String^ str2 = gcnew String( temp );
String^ str3;
String^ str4;
Console::WriteLine();
Console::WriteLine( "str1 = '{0}'", str1 );
Console::WriteLine();
Console::WriteLine( "str1 is {0} to str2.", ((0 == String::CompareOrdinal( str1, str2 )) ? (String^)"equal" : "not equal") );
CodePoints( "str1", str1 );
CodePoints( "str2", str2 );
Console::WriteLine();
// str3 is a lower case copy of str2, using English-United States culture.
Console::WriteLine( "str3 = Lower case copy of str2 using English-United States culture." );
str3 = str2->ToLower( gcnew CultureInfo( "en-US",false ) );
// str4 is a lower case copy of str2, using Turkish-Turkey culture.
Console::WriteLine( "str4 = Lower case copy of str2 using Turkish-Turkey culture." );
str4 = str2->ToLower( gcnew CultureInfo( "tr-TR",false ) );
// Compare the code points in str3 and str4.
Console::WriteLine();
Console::WriteLine( "str3 is {0} to str4.", ((0 == String::CompareOrdinal( str3, str4 )) ? (String^)"equal" : "not equal") );
CodePoints( "str3", str3 );
CodePoints( "str4", str4 );
}
/*
This example produces the following results:
str1 = 'INDIGO'
str1 is not equal to str2.
The code points in str1 are:
0049 004e 0044 0049 0047 004f
The code points in str2 are:
0130 004e 0044 0130 0047 004f
str3 = Lower case copy of str2 using English-United States culture.
str4 = Lower case copy of str2 using Turkish-Turkey culture.
str3 is equal to str4.
The code points in str3 are:
0069 006e 0064 0069 0067 006f
The code points in str4 are:
0069 006e 0064 0069 0067 006f
*/
// Sample for String.ToLower(CultureInfo)
using System;
using System.Globalization;
class Sample
{
public static void Main()
{
String str1 = "INDIGO";
// str2 = str1, except each 'I' is '\u0130' (Unicode LATIN CAPITAL I WITH DOT ABOVE).
String str2 = new String(new Char[] {'\u0130', 'N', 'D', '\u0130', 'G', 'O'});
String str3, str4;
Console.WriteLine();
Console.WriteLine("str1 = '{0}'", str1);
Console.WriteLine();
Console.WriteLine("str1 is {0} to str2.",
((0 == String.CompareOrdinal(str1, str2)) ? "equal" : "not equal"));
CodePoints("str1", str1);
CodePoints("str2", str2);
Console.WriteLine();
// str3 is a lower case copy of str2, using English-United States culture.
Console.WriteLine("str3 = Lower case copy of str2 using English-United States culture.");
str3 = str2.ToLower(new CultureInfo("en-US", false));
// str4 is a lower case copy of str2, using Turkish-Turkey culture.
Console.WriteLine("str4 = Lower case copy of str2 using Turkish-Turkey culture.");
str4 = str2.ToLower(new CultureInfo("tr-TR", false));
// Compare the code points in str3 and str4.
Console.WriteLine();
Console.WriteLine("str3 is {0} to str4.",
((0 == String.CompareOrdinal(str3, str4)) ? "equal" : "not equal"));
CodePoints("str3", str3);
CodePoints("str4", str4);
}
public static void CodePoints(String title, String s)
{
Console.Write("{0}The code points in {1} are: {0}", Environment.NewLine, title);
foreach (ushort u in s)
Console.Write("{0:x4} ", u);
Console.WriteLine();
}
}
/*
This example produces the following results:
str1 = 'INDIGO'
str1 is not equal to str2.
The code points in str1 are:
0049 004e 0044 0049 0047 004f
The code points in str2 are:
0130 004e 0044 0130 0047 004f
str3 = Lower case copy of str2 using English-United States culture.
str4 = Lower case copy of str2 using Turkish-Turkey culture.
str3 is equal to str4.
The code points in str3 are:
0069 006e 0064 0069 0067 006f
The code points in str4 are:
0069 006e 0064 0069 0067 006f
*/
' Sample for String.ToLower(CultureInfo)
Imports System.Globalization
Class Sample
Public Shared Sub Main()
Dim str1 As [String] = "INDIGO"
' str2 = str1, except each 'I' is '\u0130' (Unicode LATIN CAPITAL I WITH DOT ABOVE).
Dim str2 As New [String](New [Char]() {ChrW(&H0130), "N"c, "D"c, ChrW(&H0130), "G"c, "O"c})
Dim str3, str4 As [String]
Console.WriteLine()
Console.WriteLine("str1 = '{0}'", str1)
Console.WriteLine()
Console.WriteLine("str1 is {0} to str2.", _
IIf(0 = [String].CompareOrdinal(str1, str2), "equal", "not equal"))
CodePoints("str1", str1)
CodePoints("str2", str2)
Console.WriteLine()
' str3 is a lower case copy of str2, using English-United States culture.
Console.WriteLine("str3 = Lower case copy of str2 using English-United States culture.")
str3 = str2.ToLower(New CultureInfo("en-US", False))
' str4 is a lower case copy of str2, using Turkish-Turkey culture.
Console.WriteLine("str4 = Lower case copy of str2 using Turkish-Turkey culture.")
str4 = str2.ToLower(New CultureInfo("tr-TR", False))
' Compare the code points in str3 and str4.
Console.WriteLine()
Console.WriteLine("str3 is {0} to str4.", _
IIf(0 = [String].CompareOrdinal(str3, str4), "equal", "not equal"))
CodePoints("str3", str3)
CodePoints("str4", str4)
End Sub
Public Shared Sub CodePoints(title As [String], s As [String])
Console.Write("{0}The code points in {1} are: {0}", Environment.NewLine, title)
Dim c As Char
For Each c In s
Console.Write("{0:x4} ", AscW(c))
Next c
Console.WriteLine()
End Sub
End Class
'
'str1 = 'INDIGO'
'
'str1 is not equal to str2.
'
'The code points in str1 are:
'0049 004e 0044 0049 0047 004f
'
'The code points in str2 are:
'0130 004e 0044 0130 0047 004f
'
'str3 = Lower case copy of str2 using English-United States culture.
'str4 = Lower case copy of str2 using Turkish-Turkey culture.
'
'str3 is equal to str4.
'
'The code points in str3 are:
'0069 006e 0064 0069 0067 006f
'
'The code points in str4 are:
'0069 006e 0064 0069 0067 006f
설명
매개 변수로 지정 된 문화권의 대/소문자 규칙에 따라 culture
문자열의 대/소문자가 변경 되는 방식이 결정 됩니다.
참고
이 메서드는 현재 인스턴스의 값을 수정 하지 않습니다. 대신 현재 인스턴스의 모든 문자가 소문자로 변환 된 새 문자열을 반환 합니다.
보안 고려사항
ToLower(CultureInfo)이외의 개체에 메서드를 전달 하 CultureInfo 는 경우 CultureInfo.InvariantCulture 대/소문자 구분 작업은 문화권별 규칙을 고려 합니다. 파일 이름, 명명 된 파이프 또는 레지스트리 키와 같은 운영 체제 식별자의 소문자 또는 대문자 버전이 필요한 경우 ToLowerInvariant 또는 메서드를 사용 ToUpperInvariant 합니다. 이렇게 하면 모든 문화권에서 동일한 결과를 생성 하 고 더 효율적으로 수행 됩니다.