how can i capitalize every 1st letter in every word anyone? i'm a newbie so this would be a great help.
like this david paul to David Paul
var titleCaseStr = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(input);
string s = "Capitalize first letter in every word";
System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
System.Globalization.TextInfo textInfo = cultureInfo.TextInfo;
s = textInfo.ToTitleCase(s.ToLower());
This can be achieved simply by following method
string s = "my test string";
char[] c = s.ToArray();
bool CapitalNext = true;
string o = null;
foreach (char ch in c)
{
if (CapitalNext)
o += ch.ToString().ToUpper();
else
o += ch.ToString();
CapitalNext = false;
if (char.IsWhiteSpace(ch))
{
CapitalNext = true;
}
}
return o;