新聞中心
C#截取字符串函數(shù)是什么樣子的呢?這個(gè)在實(shí)際工作中我們經(jīng)常會(huì)遇見(jiàn)這樣的實(shí)際應(yīng)用問(wèn)題,那么具體的解決方案是什么呢?下面就向你介紹C#截取字符串函數(shù)的實(shí)現(xiàn):

創(chuàng)新互聯(lián)長(zhǎng)期為上千家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開(kāi)放共贏平臺(tái),與合作伙伴共同營(yíng)造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為新羅企業(yè)提供專業(yè)的網(wǎng)站建設(shè)、做網(wǎng)站,新羅網(wǎng)站改版等技術(shù)服務(wù)。擁有10多年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開(kāi)發(fā)。
C#截取字符串函數(shù)實(shí)例:
- //C#截取字符串函數(shù)
- public string CutStr(string sInString,int iCutLength){
- if(sInString==null ||
- sInString.Length==0 || iCutLength<=0) return "";
- int iCount=System.Text.Encoding.
- GetEncoding("Shift_JIS").GetByteCount(sInString);
- if(iCount>iCutLength){
- int iLength=0;
- //C#截取字符串函數(shù)
- for(int i=0;i
- int iCharLength=
- System.Text.Encoding.GetEncoding("Shift_JIS").
- GetByteCount(new char[]{sInString[i]});
- iLength += iCharLength;
- if(iLength==iCutLength){
- sInString=sInString.Substring(0,i+1);
- break;
- //C#截取字符串函數(shù)
- }else if(iLength>iCutLength){
- sInString=sInString.Substring(0,i);
- break;
- }
- }
- }
- return sInString;
- }
C#截取字符串函數(shù)的相關(guān)信息就向你介紹到這里,希望對(duì)你了解和學(xué)習(xí)C#截取字符串函數(shù)有所幫助。
分享文章:C#截取字符串函數(shù)實(shí)例解析
瀏覽地址:http://fisionsoft.com.cn/article/cciidie.html


咨詢
建站咨詢
