{"id":57,"date":"2008-02-11T03:15:47","date_gmt":"2008-02-11T03:15:47","guid":{"rendered":""},"modified":"2008-02-11T03:15:47","modified_gmt":"2008-02-11T03:15:47","slug":"57","status":"publish","type":"post","link":"https:\/\/www.poloo.org\/?p=57","title":{"rendered":"C#\u4e2d\u6587\u5b57\u7b26\u622a\u53d6\u51fd\u6570"},"content":{"rendered":"<p><code>\/\/\/str_value \u5b57\u7b26<br \/>\/\/\/str_len \u8981\u622a\u53d6\u7684\u5b57\u7b26\u957f\u5ea6<br \/>&nbsp;&nbsp;public string leftx(string str_value,int str_len)<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp; int p_num = 0;&nbsp;&nbsp; <br \/>&nbsp;&nbsp; int i;<br \/>&nbsp;&nbsp; string New_Str_value = \"\";<\/p>\n<p>&nbsp;&nbsp; if (str_value==\"\")<br \/>&nbsp;&nbsp; {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;New_Str_value = \"\";<br \/>&nbsp;&nbsp; }<br \/>&nbsp;&nbsp; else<br \/>&nbsp;&nbsp; {<br \/>&nbsp;&nbsp; int Len_Num = str_value.Length;<\/p>\n<p>&nbsp;&nbsp; <\/p>\n<p>&nbsp;&nbsp; \/\/if (Len_Num &lt; str_len)<br \/>&nbsp;&nbsp; \/\/{<br \/>&nbsp;&nbsp; \/\/ str_len = Len_Num;<br \/>&nbsp;&nbsp; \/\/}<\/p>\n<p>&nbsp;&nbsp; for (i = 0;i&lt;=Len_Num - 1; i++)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp; \/\/str_value.Substring(i,1);<br \/>&nbsp;&nbsp;&nbsp;&nbsp; if (i &gt;Len_Num) break;<br \/>&nbsp;&nbsp;&nbsp;&nbsp; char c&nbsp;&nbsp;= Convert.ToChar(str_value.Substring(i,1));<br \/>&nbsp;&nbsp;&nbsp;&nbsp; if&nbsp;&nbsp;(((int)c &gt; 255) || ((int)c&lt;0))<br \/>&nbsp;&nbsp;&nbsp;&nbsp; {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p_num = p_num + 2;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp; }<br \/>&nbsp;&nbsp;&nbsp;&nbsp; else<br \/>&nbsp;&nbsp;&nbsp;&nbsp; {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p_num = p_num + 1;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp; }<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp; if (p_num &gt;= str_len)<br \/>&nbsp;&nbsp;&nbsp;&nbsp; {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;New_Str_value = str_value.Substring(0,i+1);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br \/>&nbsp;&nbsp;&nbsp;&nbsp; }<br \/>&nbsp;&nbsp;&nbsp;&nbsp; else<br \/>&nbsp;&nbsp;&nbsp;&nbsp; {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;New_Str_value = str_value;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp; }<br \/>&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>&nbsp;&nbsp; <br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>&nbsp;&nbsp; return New_Str_value;<br \/>&nbsp;&nbsp;}<br \/><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/\/\/str_value \u5b57\u7b26\/\/\/str_len \u8981\u622a\u53d6\u7684\u5b57\u7b26\u957f\u5ea6&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-57","post","type-post","status-publish","format-standard","hentry","category-NET"],"_links":{"self":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/57","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=57"}],"version-history":[{"count":0,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/57\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=57"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=57"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=57"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}