System.Globalization.TextInfo
Provides culture-specific information about the case of strings, such as the case conversions, uppercase, lowercase, and title case.
Namespace
System.Globalization
Assembly
System.Runtime.dll
Inheritance
System.Object → System.Globalization.TextInfo
Syntax
public sealed class TextInfo
Constructors
Constructor | Summary |
---|---|
TextInfo() | Initializes a new instance of the TextInfo class. |
Properties
Property | Type | Summary |
---|---|---|
ListSeparator | string | Gets or sets the string that separates items in a list. |
CultureName | string | Gets the name of the culture associated with the TextInfo object. |
IsReadOnly | bool | Gets a value indicating whether the TextInfo object is read-only. |
Methods
Method | Return Type | Summary |
---|---|---|
ToUpper(string) | string | Converts the specified string to uppercase using the casing rules of the current culture. |
ToLower(string) | string | Converts the specified string to lowercase using the casing rules of the current culture. |
ToTitleCase(string) | string | Converts the specified string to title case (except for words that are entirely uppercase, which are unchanged). |
Clone() | object | Creates a shallow copy of the current TextInfo object. |
ReadOnly(TextInfo) | TextInfo | Returns a read-only wrapper for the specified TextInfo object. |
Example
// Create a TextInfo object for German culture
var germanCulture = new System.Globalization.CultureInfo("de-DE");
System.Globalization.TextInfo ti = germanCulture.TextInfo;
string lower = "strasse";
string upper = ti.ToUpper(lower); // "STRASSE"
string title = ti.ToTitleCase("ein kurzer satz"); // "Ein kurzer Satz"
Console.WriteLine($"Lower: {lower}");
Console.WriteLine($"Upper: {upper}");
Console.WriteLine($"Title: {title}");