国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

HOW TO:操作定長字符串

2024-07-21 02:29:22
字體:
供稿:網(wǎng)友

商業(yè)源碼熱門下載www.html.org.cn

public class ustringclass ustring
    private shared gencoding as system.text.encoding = system.text.encoding.getencoding("gb2312")

    public shared property encoding()property encoding() as system.text.encoding
        get
            return gencoding
        end get
        set(byval value as system.text.encoding)
            gencoding = value
        end set
    end property

    public shared function length()function length(byval s as string) as integer
        return gencoding.getbytecount(s)
    end function

    public shared function padleft()function padleft(byval s as string, byval totalwidth as integer, byval paddingchar as char) as string
        return s.padleft(totalwidth + s.length - length(s), paddingchar)
    end function

    public shared function padleft()function padleft(byval s as string, byval totalwidth as integer) as string
        return s.padleft(totalwidth + s.length - length(s))
    end function

    public shared function padright()function padright(byval s as string, byval totalwidth as integer, byval paddingchar as char) as string
        return s.padright(totalwidth + s.length - length(s), paddingchar)
    end function

    public shared function padright()function padright(byval s as string, byval totalwidth as integer) as string
        return s.padright(totalwidth + s.length - length(s))
    end function

    public shared function substring()function substring(byval line as string, byval index as integer, byval length as integer) as string
        return gencoding.getstring(gencoding.getbytes(line), index, length)
    end function

end class

測試對(duì)比:

    private sub toolstripbutton6_click()sub toolstripbutton6_click(byval sender as system.object, byval e as system.eventargs) handles toolstripbutton6.click
        dim tmp as string = "中國china"
        console.writeline(lzmtw.ustring.encoding.encodingname)


        console.writeline(lzmtw.ustring.length(tmp))
        console.writeline(tmp.length)

        console.writeline(tmp.substring(0, 2))
        console.writeline(lzmtw.ustring.substring(tmp, 0, 2))


        console.writeline(new string("*"c, 20))

        console.writeline(lzmtw.ustring.padleft(tmp, 20, "*"c))
        console.writeline(tmp.padleft(20, "*"c))

        console.writeline(lzmtw.ustring.padright(tmp, 20, "*"c))
        console.writeline(tmp.padright(20, "*"c))

        console.writeline(lzmtw.ustring.padleft(tmp, 20))
        console.writeline(tmp.padleft(20))

        console.writeline(lzmtw.ustring.padright(tmp, 20))
        console.writeline(tmp.padright(20))

    end sub

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 于都县| 曲麻莱县| 于田县| 宜兰市| 孝感市| 海伦市| 上思县| 临漳县| 政和县| 谷城县| 鹤山市| 万盛区| 丁青县| 城固县| 富源县| 茂名市| 兴城市| 体育| 山东| 苍梧县| 襄汾县| 元阳县| 石首市| 乐平市| 松桃| 舞钢市| 海城市| 班戈县| 梅河口市| 渝中区| 宁都县| 蓬莱市| 陆良县| 盐池县| 和顺县| 洪洞县| 清涧县| 丹巴县| 新田县| 南昌县| 乳源|