Is it possible to Convert a string to Title Case in Xamarin.Forms?

前端 未结 5 873
遇见更好的自我
遇见更好的自我 2021-01-22 13:46

So in my program I have an Entry like so:


and this is bound to a property.

I ha

5条回答
  •  难免孤独
    2021-01-22 13:56

    You can use Linq to split all the words and capitalize the first letter, something like this:

    string input = "test of title case";
    string output=String.Join(" ",input.Split(' ')
                             .ToList()
                             .Select(x => x = x.First().ToString().ToUpper() + x.Substring(1)));
    

    In order for this to work, the separator of words must be a space always, it won't work with commas, periods etc...

提交回复
热议问题