Home  |  Delphi .net Home  |  System.Globalization.TextInfo  |  ToTitleCase Method
  
ToTitleCase  
Method  
Converts a String to Title Case according to the current culture
TextInfo Class
System.Globalization NameSpace
CF1.  Function ToTitleCase ( Text : String ) : String;
CF : Methods with this mark are Compact Framework Compatible
Description
The given Text string is capitalised according to the current culture.
 
For example, for Britain, the given Text string is scanned for words, as separated by white space. Each word has the first character set to Upper case and remaining characters set to Lower case.
Microsoft MSDN Links
System.Globalization
System.Globalization.TextInfo
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

uses
  System.Globalization;

var
  gbCulture  : System.Globalization.CultureInfo;
  gbTextInfo : System.Globalization.TextInfo;
  myString   : String;

begin
  // Create a British culture info object
  gbCulture  := CultureInfo.Create('en-GB');

  // Get the TextInfo object from this culture
  gbTextInfo := gbCulture.TextInfo;

  // Display a string in Lower, Upper and Title case
  myString := 'Hello there from Delphi Basics';

  Console.WriteLine('Original   : ' + myString);
  Console.WriteLine;
  Console.WriteLine('Title case : ' + gbTextInfo.ToTitleCase(myString));
  Console.WriteLine('Lower case : ' + gbTextInfo.ToLower(myString));
  Console.WriteLine('Upper case : ' + gbTextInfo.ToUpper(myString));

  Console.ReadLine;
end.
   Original   : Hello there from Delphi Basics
  
   Title case : Hello There From Delphi Basics
   Lower case : hello there from delphi basics
   Upper case : HELLO THERE FROM DELPHI BASICS
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author