当前位置: 首页>>代码示例>>C#>>正文


C# CultureInfo.ToTitleCase方法代码示例

本文整理汇总了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();
     }
 }
开发者ID:NosDeveloper2,项目名称:RecruitGenie,代码行数:24,代码来源:add-address.aspx.cs

示例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 />";
//.........这里部分代码省略.........
开发者ID:Enthri,项目名称:codereddit,代码行数:101,代码来源:PageBuilder.cs

示例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 />";

//.........这里部分代码省略.........
开发者ID:Enthri,项目名称:codereddit,代码行数:101,代码来源:PageBuilder.cs

示例4: ToTitleCase

 public static string ToTitleCase(this string input)
 {
     TextInfo myTI = new CultureInfo("en-US", false).TextInfo;
     input = myTI.ToTitleCase(input);
     return input;
 }
开发者ID:HansS,项目名称:TelerikAcademy-homework,代码行数:6,代码来源:ToTitleCase.cs

示例5: Title

 public static string Title(string s)
 {
     TextInfo textInfo = new CultureInfo("en-US",false).TextInfo;
     return textInfo.ToTitleCase(s);
 }
开发者ID:ColtonPhillips,项目名称:vtn-theme,代码行数:5,代码来源:GenerateTheme.cs

示例6: CapitalFirstLetter

 public static string CapitalFirstLetter(this string input)
 {
     TextInfo capitalFirst = new CultureInfo("en-US", false).TextInfo;
     string result = capitalFirst.ToTitleCase(input);
     return result;
 }
开发者ID:bankova,项目名称:CSharp,代码行数:6,代码来源:CapitalFirstLetter.cs

示例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);
        }
开发者ID:BlueInt32,项目名称:Tools,代码行数:9,代码来源:LionelExtensions.String.cs

示例8: ConvertTo_ProperCase

 public static string ConvertTo_ProperCase(string text)
 {
     TextInfo myTI = new CultureInfo("en-US", false).TextInfo;
     return myTI.ToTitleCase(text.ToLower());
 }
开发者ID:coderlazy,项目名称:kloserbsb,代码行数:5,代码来源:Utils.cs


注:本文中的CultureInfo.ToTitleCase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。