本文整理汇总了C#中CultureInfo.ToTitleCase方法的典型用法代码示例。如果您正苦于以下问题:C# CultureInfo.ToTitleCase方法的具体用法?C# CultureInfo.ToTitleCase怎么用?C# CultureInfo.ToTitleCase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CultureInfo
的用法示例。
在下文中一共展示了CultureInfo.ToTitleCase方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveAddress
private void SaveAddress()
{
var ti = new CultureInfo("en-gb", false).TextInfo;
var address = new Address
{
Type = ddlType.SelectedValue,
Address1 = txtAddress1.Text,
Address2 = txtAddress2.Text,
Address3 = txtAddress3.Text,
City = txtCity.Text,
Postcode = txtPostcode.Text,
County = txtCounty.Text,
Country = ddlCountry.SelectedValue,
RefId = Convert.ToInt32(lblRefId.Text),
RefType = ti.ToTitleCase(lblType.Text.Trim())
};
var success = new Addresses().AddAddress(address);
if (success)
{
//reload the list
ScriptManager.RegisterStartupScript(this, this.GetType(), "retrieve", "try { parent.RetrieveAddresses();} catch (e) { }", true);
ClearEntries();
}
}
示例2: Process_User
public static void Process_User(ref string page, ref string output, string reddit_url)
{
//trim any querystring variables off our reddit_url so we don't do things like
// /r/reddit.com/?after=blah?after=blah2
int idx = reddit_url.IndexOf('?');
if (idx > 0)
reddit_url = reddit_url.Substring(0, idx);
//For User pages
JavaScriptSerializer ser = new JavaScriptSerializer();
Thing thing = ser.Deserialize<Thing>(page.Replace("\"replies\": \"\"", "\"replies\": {}"));
//Help us to title case the titles
TextInfo myTI = new CultureInfo("en-US", false).TextInfo;
//Make a regex for cleaning titles into nice function names
Regex regEx = new Regex("[^a-zA-Z0-9 ]");
string title = "";
string body = "";
string author = "";
string date = "";
string ups = "";
string downs = "";
string net_ups = "";
string subreddit = "";
string over_18 = "";
string selftext = "";
string name = "";
string id = "";
string num_comments = "";
string url = "";
string is_self = "";
string link_id = "";
//Replace these words with functions that generate unique names
string lit_title = "full_title";
string lit_upvote = "upvotes";
string lit_comment = "Load_Comments";
PrintIncludes(ref output);
output += "<span class=\"keyword\">public class</span> <span class=\"class\">" + thing.data.children[0].data.author + "</span><br />";
output += "{<br />";
output += "<div class=\"indent\">";
foreach (Thing child in thing.data.children)
{
if (child.data.title != null)
{
title = regEx.Replace(child.data.title, "").Replace(' ', '_');
title = myTI.ToTitleCase(title);
}
else
{
title = regEx.Replace(child.data.link_title, "").Replace(' ', '_');
title = myTI.ToTitleCase(title);
}
if (child.data.body != null)
body = child.data.body;
author = child.data.author;
date = new DateTime(1970, 1, 1).AddSeconds(child.data.created_utc).ToString();
ups = child.data.ups;
downs = child.data.downs;
if (child.data.score != null)
net_ups = child.data.score;
else
net_ups = (int.Parse(ups) - int.Parse(downs)).ToString();
subreddit = child.data.subreddit;
over_18 = child.data.over_18;
selftext = child.data.selftext;
name = child.data.name;
id = child.data.id;
num_comments = child.data.num_comments;
url = child.data.url;
is_self = child.data.is_self;
if (child.data.link_id != null)
link_id = child.data.link_id.Substring(3, child.data.link_id.Length-3); //need to chop off the preceding "type"
else
link_id = "whyistherenolinkid?";
//If it's a self post, we should redirect the url to ourselves so the user doesn't jump out to full reddit
if (is_self == "True")
url = "?url=" + System.Web.HttpUtility.HtmlEncode(url + ".json");
output += "<span class=\"comment\">//" + date + " : <a class=\"comment\" href=\"?url=" + System.Web.HttpUtility.HtmlEncode("http://www.reddit.com/user/" + author + "/" + ".json") + "\">" + author + "</a></span><br />";
output += "<span class=\"keyword\">protected void</span> <a href=\"?url=" + System.Web.HttpUtility.HtmlEncode("http://www.reddit.com/r/" + subreddit + "/comments/" + link_id + "/" + ".json") + "\">" + title.Substring(0, Math.Min(20, title.Length)) + "</a>(<span class=\"keyword\">Category</span> <a href=\"?url=" + System.Web.HttpUtility.HtmlEncode("http://www.reddit.com/r/" + subreddit + "/" + ".json") + "\">" + subreddit + "</a> , ";
if (over_18 == "True")
output += "<span class=\"class\">Boolean</span> IsAdult, <br />";
output += "<span class=\"class\">EventArgs</span> e)<br />";
output += "{<br />";
output += "<div class=\"indent\">";
output += "<span class=\"keyword\">string </span>" + lit_title + " = <span class=\"string\">\"<a class=\"string\" href=\"?url=" + System.Web.HttpUtility.HtmlEncode("http://www.reddit.com/r/" + subreddit + "/comments/" + link_id + "/" + ".json") + "\">" + title + "</a>\"</span>;<br />";
output += "<span class=\"comment\">/*<br />";
output += body + "</a>;<br />";
output += "*/</span><br />";
output += "<span class=\"keyword\">int </span>" + lit_upvote + " = +" + ups + "-" + downs + ";<br />";
output += "<span class=\"class\">Debug</span>.Assert(" + lit_upvote + " == " + net_ups + ");<br />";
//.........这里部分代码省略.........
示例3: Process_Comments
public static void Process_Comments(ref string page, ref string output)
{
//For comment pages
JavaScriptSerializer ser = new JavaScriptSerializer();
Thing[] things = ser.Deserialize<Thing[]>(page.Replace("\"replies\": \"\"", "\"replies\": {}"));
Thing child = things[0].data.children[0]; //The start post is the first child
Thing reply_thing = things[1];
//Help us to title case the titles
TextInfo myTI = new CultureInfo("en-US", false).TextInfo;
//Make a regex for cleaning titles into nice function names
Regex regEx = new Regex("[^a-zA-Z0-9 ]");
string title = "";
string author = "";
string date = "";
string ups = "";
string downs = "";
string net_ups = "";
string subreddit = "";
string over_18 = "";
string selftext = "";
string name = "";
string id = "";
string num_comments = "";
string url = "";
string is_self = "";
//Replace these words with functions that generate unique names
string lit_title = "full_title";
string lit_upvote = "upvotes";
string lit_comment = "Load_Comments";
PrintIncludes(ref output);
title = regEx.Replace(child.data.title, "").Replace(' ', '_');
title = myTI.ToTitleCase(title);
author = child.data.author;
date = new DateTime(1970, 1, 1).AddSeconds(child.data.created_utc).ToString();
ups = child.data.ups;
downs = child.data.downs;
net_ups = child.data.score;
subreddit = child.data.subreddit;
over_18 = child.data.over_18;
selftext = child.data.selftext;
name = child.data.name;
id = child.data.id;
num_comments = child.data.num_comments;
url = child.data.url;
is_self = child.data.is_self;
//If it's a self post, we should redirect the url to ourselves so the user doesn't jump out to full reddit
if (is_self == "True")
url = "?url=" + System.Web.HttpUtility.HtmlEncode(url + ".json");
output += "<span class=\"comment\">//" + date + " : <a class=\"comment\" href=\"?url=" + System.Web.HttpUtility.HtmlEncode("http://www.reddit.com/user/" + author + "/" + ".json") + "/\">" + author + "</a></span><br />";
output += "<span class=\"keyword\">public class</span> <span class=\"class\"><a href=\"" + url + "\">" + title.Substring(0, Math.Min(20, title.Length)) + "</a></span> : <a href=\"?url=" + System.Web.HttpUtility.HtmlEncode("http://www.reddit.com/r/" + subreddit) + "/" + ".json" +"\">" + subreddit + "</a><br />";
output += "{<br />";
output += "<div class=\"indent\">";
output += "<span class=\"keyword\">public string </span>contributors;<br />";
output += "<span class=\"keyword\">public int </span>tmpScore;<br />";
output += "<span class=\"keyword\">public DateTime </span>tmpDate;<br />";
output += "<span class=\"keyword\">public string </span>" + lit_title + ";<br />";
output += "<span class=\"keyword\">public int </span>" + lit_upvote + ";<br />";
output += "<span class=\"keyword\">public bool</span> IsAdult; <br />";
output += "<br />";
output += "<span class=\"comment\">//Constructor</span><br />";
output += "<span class=\"keyword\">public </span> <span class=\"class\"><a href=\"" + url + "\">" + title.Substring(0, Math.Min(20, title.Length)) + "()</a></span><br />";
output += "{<br />";
output += "<div class=\"indent\">";
output += "contributors = <span class=\"string\">\"\"</span>;<br />";
output += "tmpScore = <span class=\"keyword\">new </span><span class=\"class\">Random()</span>.Next();<br />";
output += "tmpDate = <span class=\"keyword\">null</span>;<br />";
output += lit_title + " = <span class=\"string\">\"<a class=\"string\" href=\"" + url + "\">" + title + "</a>\"</span>;<br />";
output += lit_upvote + " = +" + ups + "-" + downs + ";<br />";
if (over_18 == "True")
output += "IsAdult = <span class=\"keyword\">true</span>;<br />";
else
output += "IsAdult = <span class=\"keyword\">false</span>;<br />";
output += "<span class=\"class\">Debug</span>.Assert(" + lit_upvote + " == " + net_ups + ");<br />";
if (selftext != null && selftext != "")
{
output += "<span style=\"cursor:pointer;\" onclick=\"javascript:ToggleDiv('" + id + "')\"><span class=\"keyword\">#region</span> selfText</span><br />";
output += "<div id=\"" + id + "\" style=\"display:none\">";
output += "<span class=\"comment\">/*<br />";
output += selftext + "<br />";
output += "*/</span><br />";
output += "<span class=\"keyword\">#endregion</span><br />";
output += "</div>";
}
output += "<br />";
output += "</div>";
output += "}<br /><br />";
//.........这里部分代码省略.........
示例4: ToTitleCase
public static string ToTitleCase(this string input)
{
TextInfo myTI = new CultureInfo("en-US", false).TextInfo;
input = myTI.ToTitleCase(input);
return input;
}
示例5: Title
public static string Title(string s)
{
TextInfo textInfo = new CultureInfo("en-US",false).TextInfo;
return textInfo.ToTitleCase(s);
}
示例6: CapitalFirstLetter
public static string CapitalFirstLetter(this string input)
{
TextInfo capitalFirst = new CultureInfo("en-US", false).TextInfo;
string result = capitalFirst.ToTitleCase(input);
return result;
}
示例7: ToTitleCase
public static string ToTitleCase(this string str)
{
if (string.IsNullOrEmpty(str))
return null;
TextInfo textInfo = new CultureInfo("fr-FR", false).TextInfo;
return textInfo.ToTitleCase(str);
}
示例8: ConvertTo_ProperCase
public static string ConvertTo_ProperCase(string text)
{
TextInfo myTI = new CultureInfo("en-US", false).TextInfo;
return myTI.ToTitleCase(text.ToLower());
}