This is not true
c# strings aren't arrays like in c.
They are []char
. You can itterate over them, get the length etc. Also are immutable. See MSDN:
String whose value is text. Internally, the text is stored as a sequential read-only collection of Char objects.
In the spirit of the context, such (I agree non-most-elegant) solution should work even for long full names:
public static string GetTitleCase(string fullName)
{
string[] names = fullName.Split(' ');
List<string> currentNameList = new List<string>();
foreach (var name in names)
{
if (Char.IsUpper(name[0]))
{
currentNameList.Add(name);
}
else
{
currentNameList.Add(Char.ToUpper(name[0]) + name.Remove(0, 1));
}
}
return string.Join(" ", currentNameList.ToArray()).Trim();
}