{"id":225,"date":"2010-09-30T11:52:21","date_gmt":"2010-09-30T11:52:21","guid":{"rendered":"http:\/\/enjoyasp.net\/?p=225"},"modified":"2010-10-13T06:57:25","modified_gmt":"2010-10-13T06:57:25","slug":"%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/enjoyasp.net\/index.php\/2010\/09\/30\/%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%93%8d%e4%bd%9c\/","title":{"rendered":"\u5b57\u7b26\u4e32\u64cd\u4f5c"},"content":{"rendered":"<p>1.\u5b57\u7b26\u4e32\u62fc\u63a5\uff1a<\/p>\n<p>string msg = &#8221; Hello, &#8221; + thisUser.Name + &#8220;.Today is &#8221; + DateTime.Now.ToString( ));<\/p>\n<p>\u66f4\u6709\u6548\u7387\u7684\u5199\u6cd5\uff1a<\/p>\n<p>string msg = string .Format ( &#8221; Hello, {0}. Today is {1}&#8221; , thisUser.Name, DateTime.Now.ToString( ));<\/p>\n<p>2.\u5927\u91cf\u6570\u636e\u62fc\u63a5\u5219\u4f7f\u7528StringBuilder\u3002<\/p>\n<p>3.\u5b57\u7b26\u4e32\u7684\u6bd4\u8f83\uff1a<\/p>\n<p>\uff081\uff09\u5224\u65ad\u662f\u5426\u662f\u7a7a\u4e32<\/p>\n<p>if ( str != &#8221; &#8221; )\u4e0eif ( str == &#8221; &#8221; )<\/p>\n<p>\u66f4\u6709\u6548\u7387\u7684\u5199\u6cd5\uff1a<\/p>\n<p>if ( str.Length != 0 )\u4e0eif ( str.Length ==0 )<\/p>\n<p>\u6709\u6548\u7387\u4e14\u53ef\u8bfb\u6027\u66f4\u597d\u7684\u5199\u6cd5\uff1a<\/p>\n<p>if ( str != string .Empty )\u4e0eif( str .Equals( string .Empty)<\/p>\n<p>\u6bd4\u8f83\u662f\u5426\u662fNULL\u6216\u7a7a\u5b57\u4e32\u7528\uff1astring.IsNullOrEmpty<\/p>\n<p>\uff082\uff09 \u5b57\u7b26\u4e32\u4e4b\u95f4\u7684\u6bd4\u8f83<\/p>\n<p>?if (string.Compare(s,b,true) ==0)?? s&lt;b \u5c0f\u4e8e0\uff0cs==b ,0 s&gt;b \u5927\u4e8e0 \u8fd9\u79cd\u6bd4\u8f83\u7528true\u6307\u5b9a\u5ffd\u7565\u5927\u5c0f\u5199\uff0c\u4e0d\u7528\u518dtoUpper()\u4e4b\u7c7b<\/p>\n<p>4,\u622a\u53d6\u6700\u540e\u4e00\u4f4d\u4e4b\u524d\u7684\u6570\u636eTrimEnd<br \/>\nstring s = &#8220;1,2,3,4,5,&#8221;;<br \/>\nConsole.Write(s.ToString().TrimStart(&#8216;,&#8217;));<br \/>\nConsole.Read();<\/p>\n<p>5,\u5206\u5272\u5b57\u7b26\u4e32:<br \/>\n1\uff09\u5355\u4e2a\u5b57\u7b26\uff1astring[] args = str.split(&#8216;,&#8217;);<br \/>\n2)\u5b57\u7b26\u4e32\u5207\u5206\uff1astring[] arrays = Regex.Splits,&#8221;##&#8221;,RegexOptions.IgnoreCase); \/\/System.Text.RegularExpressions;<\/p>\n<p>6,\u8f6c\u6362\uff1a<\/p>\n<p>int.Parse:\u7528\u6cd5\uff0c\u5c06\u629b\u51fa\u5f02\u5e38<\/p>\n<p>Convert.ToInt32(s): \u5f53s\u4e3a\u7a7a\u65f6\u4e0d\u629b\u51fa\u5f02\u5e38\uff0c\u5f53\u4e3astring.Empty\u6216\u5b57\u7b26\u4e32\u65f6&#8221;sdfsd&#8221;\u5219\u629b\u51fa\u5f02\u5e38<\/p>\n<p>int.TryParse(s,out i) \u4e0d\u629b\u51fa\u5f02\u5e38\uff0c\u82e5\u6709\u5f02\u5e38\uff0c\u8fd4\u56defalse,<\/p>\n<p>\/\/\u6027\u80fd\uff1aint.TryParse &gt; int.Parse &gt; Convert.ToInt32<\/p>\n<p>7\uff0c\u6c42\u4e24\u4e2a\u6574\u6570\u7684\u5546\u53ca\u4f59\u6570<\/p>\n<p>int yes; double s = Math.DivRem(5,0,out yes);<\/p>\n<p>8, \u8fd4\u56de&gt;=\u6307\u5b9a\u6570\u5b57\u7684\u6700\u5c0f\u6574\u6570 Math.Ceiling(0.5)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.\u5b57\u7b26\u4e32\u62fc\u63a5\uff1a string msg = &#8221; Hello, &#8221; + thisUser [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-225","post","type-post","status-publish","format-standard","hentry","category-csharp"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/225","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/comments?post=225"}],"version-history":[{"count":0,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/225\/revisions"}],"wp:attachment":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/media?parent=225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/categories?post=225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/tags?post=225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}