本文整理汇总了C#中System.Globalization.CultureInfo.ToTitleCase方法的典型用法代码示例。如果您正苦于以下问题:C# CultureInfo.ToTitleCase方法的具体用法?C# CultureInfo.ToTitleCase怎么用?C# CultureInfo.ToTitleCase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Globalization.CultureInfo
的用法示例。
在下文中一共展示了CultureInfo.ToTitleCase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupSpellBook_Load
private void SetupSpellBook_Load(object sender, EventArgs e)
{
var ti = new CultureInfo("en-ZA", false).TextInfo;
txtAddonAuthor.Text = ti.ToTitleCase(Environment.UserName);
var machineName = new string(Environment.MachineName.Where(char.IsLetter).ToArray()).ToLower();
txtAddonName.Text = ti.ToTitleCase(machineName);
txtAddonAuthor.Text = SpellBook.AddonAuthor;
txtAddonName.Text = ConfigFile.ReadValue("PixelMagic", "AddonName");
cmbKeyBind.DataSource = Enum.GetNames(typeof(WoW.Keys));
try
{
var intVer = SpellBook.InterfaceVersion.Replace("\n", "").Replace("\r", "");
foreach (var item in cmbWowVersion.Items)
{
if (item.ToString().Contains(intVer)) cmbWowVersion.SelectedItem = item;
}
}
catch(Exception ex)
{
// Do nothing - ignore
}
dgSpells.DataSource = SpellBook.dtSpells;
dgAuras.DataSource = SpellBook.dtAuras;
}
示例2: WordView
public WordView(CGRect frame, string title, string value)
{
Init();
Frame = frame;
var textInfo = new CultureInfo("en-US",false).TextInfo;
title = textInfo.ToTitleCase(title);
value = textInfo.ToTitleCase(value);
//Title label
_title = new UILabel(new CGRect(0, 45, frame.Width, 50))
{
TextAlignment = UITextAlignment.Center,
TextColor = "3C3C3C".ToUIColor(),
Font = UIFont.FromName("Raleway-SemiBold", 32),
Text = title
};
Add(_title);
//Word label
_word = new UILabel(new CGRect(0, 108, frame.Width, 59))
{
TextAlignment = UITextAlignment.Center,
TextColor = "3C3C3C".ToUIColor(),
Font = UIFont.FromName("Raleway-Regular", 32),
Text = value
};
Add(_word);
}
示例3: AjaxAction
public ActionResult AjaxAction(string nome, string sobrenome)
{
Thread.Sleep(3000);
var ti = new CultureInfo("pt-BR").TextInfo;
var nomeFormatado = string.Format("{0} {1}", ti.ToTitleCase(nome), ti.ToTitleCase(sobrenome));
return PartialView("PartialNomes", nomeFormatado);
}
示例4: TitleCase
public void TitleCase ()
{
TextInfo ti = new CultureInfo ("en-US", false).TextInfo;
Assert.AreEqual (" The Dog", ti.ToTitleCase (" the dog"));
Assert.AreEqual (" The Dude", ti.ToTitleCase (" The Dude"));
Assert.AreEqual ("La Guerra Yla Paz", ti.ToTitleCase ("la Guerra yLa pAz"));
Assert.AreEqual ("\tTab\tAnd\tPeace", ti.ToTitleCase ("\ttab\taNd\tpeaCE"));
}
示例5: TitleCase
public void TitleCase ()
{
TextInfo ti = new CultureInfo ("en-US", false).TextInfo;
Assert.AreEqual (" The Dog", ti.ToTitleCase (" the dog"), "#1");
Assert.AreEqual (" The Dude", ti.ToTitleCase (" The Dude"), "#2");
Assert.AreEqual ("La Guerra Yla Paz", ti.ToTitleCase ("la Guerra yLa pAz"), "#3");
Assert.AreEqual ("\tTab\tAnd\tPeace", ti.ToTitleCase ("\ttab\taNd\tpeaCE"), "#4");
Assert.AreEqual ("This_Is\uFE58A\u0095String\u06D4With\uFE33Separators", ti.ToTitleCase ("this_is\uFE58a\u0095string\u06D4with\uFE33separators"), "#5");
}
示例6: ActorNameGenerator
static ActorNameGenerator()
{
TextInfo myTI = new CultureInfo("en-gb", false).TextInfo;
//Load everything
using (TextReader reader = new StreamReader(folderPath + Path.DirectorySeparatorChar + "HumanNames" + Path.DirectorySeparatorChar + "FemaleNames.txt"))
{
femaleHuman.AddRange(reader.ReadToEnd().ToLower().Replace("\r", "").Split('\n').Where(r => !String.IsNullOrEmpty(r)));
}
using (TextReader reader = new StreamReader(folderPath + Path.DirectorySeparatorChar + "HumanNames" + Path.DirectorySeparatorChar + "MaleNames.txt"))
{
maleHuman.AddRange(reader.ReadToEnd().ToLower().Replace("\r", "").Split('\n').Where(r => !String.IsNullOrEmpty(r)));
}
using (TextReader reader = new StreamReader(folderPath + Path.DirectorySeparatorChar + "HumanNames" + Path.DirectorySeparatorChar + "Surnames.txt"))
{
humanSurname.AddRange(reader.ReadToEnd().ToLower().Replace("\r", "").Split('\n').Where(r => !String.IsNullOrEmpty(r)));
}
using (TextReader reader = new StreamReader(folderPath + Path.DirectorySeparatorChar + "OrcNames" + Path.DirectorySeparatorChar + "FirstName.txt"))
{
orcName.AddRange(reader.ReadToEnd().Replace("\r", "").Split('\n').Where(r => !String.IsNullOrEmpty(r)));
}
using (TextReader reader = new StreamReader(folderPath + Path.DirectorySeparatorChar + "OrcNames" + Path.DirectorySeparatorChar + "SurnameAft.txt"))
{
orcSurnameAft.AddRange(reader.ReadToEnd().Replace("\r", "").Split('\n').Where(r => !String.IsNullOrEmpty(r)));
}
using (TextReader reader = new StreamReader(folderPath + Path.DirectorySeparatorChar + "OrcNames" + Path.DirectorySeparatorChar + "SurnameFore.txt"))
{
orcSurnameFore.AddRange(reader.ReadToEnd().Replace("\r", "").Split('\n').Where(r => !String.IsNullOrEmpty(r)));
}
//Title case all of them
for (int i = 0; i < femaleHuman.Count; i++)
{
femaleHuman[i] = myTI.ToTitleCase(femaleHuman[i]);
}
for (int i = 0; i < maleHuman.Count; i++)
{
maleHuman[i] = myTI.ToTitleCase(maleHuman[i]);
}
for (int i = 0; i < humanSurname.Count; i++)
{
humanSurname[i] = myTI.ToTitleCase(humanSurname[i]);
}
random = new Random();
}
示例7: Capitalize
public static string Capitalize(this string original, bool onlyFirst=false, string culture="en-US")
{
TextInfo textInfo = new CultureInfo(culture, false).TextInfo;
original = original.Trim();
if (string.IsNullOrWhiteSpace(original))
return null;
if (onlyFirst && original.Length != 1)
{
return textInfo.ToTitleCase(original.Substring(0, 1)) + original.Substring(1);
}
else
{
return textInfo.ToTitleCase(original);
}
}
示例8: Main
static void Main(string[] args)
{
var syntaxTree = SyntaxTree.ParseFile("Person.cs");
var allNodes = syntaxTree.GetRoot().DescendantNodes();
var fields = allNodes.OfType<FieldDeclarationSyntax>().SelectMany(
f => f.Declaration.Variables.Select(
v => v.Identifier.ValueText)).ToList();
var methods = allNodes.OfType<MethodDeclarationSyntax>().Select(
m => m.Identifier.ValueText);
var textInfo = new CultureInfo("nb-NO").TextInfo;
foreach (var field in fields)
{
var trimmedAndCapitalizedFieldName = textInfo.ToTitleCase(field.TrimStart('_'));
var getterName = "Get" + trimmedAndCapitalizedFieldName;
var setterName = "Set" + trimmedAndCapitalizedFieldName;
if (methods.Contains(getterName))
Console.WriteLine("there seems to be a getter for field '{0}': {1}", field, getterName);
if (methods.Contains(setterName))
Console.WriteLine("there seems to be a setter for field '{0}': {1}", field, setterName);
}
Console.Read();
}
示例9: GetPrimePlatSellOrders
public static async Task<long?> GetPrimePlatSellOrders(string primeName)
{
CacheEntry<long?> cacheItem;
if (_marketCache.TryGetValue(primeName, out cacheItem))
{
if (!cacheItem.IsExpired(_expirationTimespan))
{
return cacheItem.Value;
}
}
var textInfo = new CultureInfo("en-US", false).TextInfo;
var partName = textInfo.ToTitleCase(primeName.ToLower());
if (_removeBPSuffixPhrases.Any(suffix => partName.EndsWith(suffix + " Blueprint")))
{
partName = partName.Replace(" Blueprint", "");
}
// Since Warframe.Market is still using the term Helmet instead of the new one, TODO: this might change
partName = partName.Replace("Neuroptics", "Helmet");
if (_fixedQueryStrings.ContainsKey(partName))
{
//Some of Warframe.Market's query strings are mangled (extra spaces, misspellings, words missing) fix them manually...
partName = _fixedQueryStrings[partName];
}
string jsonData;
using (var client = new WebClient())
{
var uri = new Uri(_baseUrl + Uri.EscapeDataString(partName));
try
{
jsonData = await client.DownloadStringTaskAsync(uri);
dynamic result = JsonConvert.DeserializeObject(jsonData);
// when the server responds anything that is not 200 (HTTP OK) don't bother doing something else
if (result.code != 200)
{
Debug.WriteLine($"Error with {partName}, Status Code: {result.code.Value}");
_marketCache[primeName] = new CacheEntry<long?>(null);
return null;
}
IEnumerable<dynamic> sellOrders = result.response.sell;
long? smallestPrice = sellOrders.Where(order => order.online_status).Min(order => order.price);
_marketCache[primeName] = new CacheEntry<long?>(smallestPrice);
return smallestPrice;
}
catch
{
return null;
}
}
}
示例10: MIFieldValue
public MIFieldValue(string field, string value, string prefix)
{
Value = value;
TextInfo ti = new CultureInfo("en-US", false).TextInfo;
string tempName = string.Empty;
foreach (char c in field)
{
if (Char.IsLetterOrDigit(c))
{
tempName += c;
}
else if (c == '(' || c == ')')
{
continue;
}
else
{
tempName += " ";
}
}
tempName = ti.ToTitleCase(tempName.Trim()).Replace(" ", "");
FieldWithoutPadding = string.Format("{0}_{1}", prefix, tempName);
Field = string.Format("{0}{1}{2}", paddingChar, FieldWithoutPadding, paddingChar);
}
示例11: GetMonthsListForDropDown
public IEnumerable<SelectListItem> GetMonthsListForDropDown()
{
var textInfo = new CultureInfo("en-US", false).TextInfo;
var items = new List<SelectListItem>();
//var selFirstListItem = new SelectListItem { Value = "", Text = "--- Choose ---" };
//items.Add(selFirstListItem);
var selItems = new List<SelectListItem>();
if (DateTimeFormatInfo
.CurrentInfo != null)
{
selItems = DateTimeFormatInfo
.CurrentInfo
.MonthNames
.Select((monthName, index) =>
new SelectListItem
{
Value = (index + 1).ToString(CultureInfo.InvariantCulture),
Text = textInfo.ToTitleCase(monthName)
}).Where(p => p.Text != "").ToList();
}
selItems = DateTimeFormatInfo
.InvariantInfo
.MonthNames
.Select((monthName, index) =>
new SelectListItem
{
Value = (index + 1).ToString(CultureInfo.InvariantCulture),
Text = monthName
}).Where(p => p.Text != "").ToList();
items.AddRange(selItems);
return items;
}
示例12: ConvertToTitleCase
public string ConvertToTitleCase(string title)
{
TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
title = textInfo.ToTitleCase(title);
return title;
}
示例13: Start
// Use this for initialization
void Start () {
if (string.IsNullOrEmpty(JumpToLevel)) {
logger.LogError("Level", "Naming Error");
}
System.Globalization.TextInfo textInfo = new System.Globalization.CultureInfo("en-US", false).TextInfo;
JumpToLevel = textInfo.ToTitleCase(JumpToLevel);
}
示例14: SetCase
private static string SetCase(this string InputText)
{
TextInfo _textInfo = new CultureInfo(CultureInfo.CurrentCulture.ToString(), false).TextInfo;
string _output = _textInfo.ToTitleCase(InputText.ToLower());
return _output;
}
示例15: ToTitleCase
private static string ToTitleCase(string texto, bool manterOqueJaEstiverMaiusculo)
{
texto = texto.Trim();
if (!manterOqueJaEstiverMaiusculo) texto = texto.ToLower();
TextInfo textInfo = new CultureInfo("pt-BR", false).TextInfo;
return textInfo.ToTitleCase(texto);
}