string conversion, first character upper of each word

string name = "HECHT, WILLIAM";
string s = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(name.ToLower());

(note it only works lower-to-upper, hence starting lower-case)


I'd just like to include an answer that points out that although this seems simple in theory, in practice properly capitalizing the names of everyone can be very complicated:

  • Peter O'Toole
  • Xavier Sala-i-Martin
  • Salvador Domingo Felipe Jacinto Dalí i Domènech
  • Francis Sheehy-Skeffington
  • Asma al-Assad
  • Maggie McIntosh
  • Vincent van Gogh

Anyway, just something to think about.

Tags:

C#

String