本文介绍了麦当劳以ProperCase在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你会如何转换名称适当情况下,在C#?

How would you convert names to proper case in C#?

我有我想证明的名单。

例如:麦当劳麦当劳或奥布莱恩奥布莱恩

For example: mcdonalds to McDonalds or o'brien to O'Brien.

推荐答案

有绝对没有办法对计算机只是奇迹般地知道,在麦当劳的第一个D应该大写。所以,我认为有两个选择。

There is absolutely no way for a computer just to magically know that the first "D" in "McDonalds" should be capitalized. So, I think there are two choices.


  1. 有人在那里可能有一个软件或将为此库你

  1. Someone out there may have a piece of software or a library that will do this for you.

除了上述,你唯一的选择就是采取如下方法:首先,我想查找名字有字的字典有趣的资本。显然,你必须提供本词典自己,除非已经存在。二,报考纠正一些明显的那些,像O'和Mac和麦当劳开始凯尔特人的名字,虽然赐名足够大的游泳池,这样的算法,无疑将有大量的误报的算法。最后,利用每一个不符合前两个标准名称的第一个字母。

Barring that, your only choice is to take the following approach: First, I'd look up the name in a dictionary of words that have "interesting" capitalization. Obviously you'd have to provide this dictionary yourself, unless one exists already. Second, apply an algorithm that corrects some of the obvious ones, like Celtic names beginning with O' and Mac and Mc, although given a large enough pool of names, such an algorithm will undoubtedly have a lot of false positives. Lastly, capitalize the first letter of every name that doesn't meet the first two criteria.

这篇关于麦当劳以ProperCase在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 12:34