国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 襄垣县| 池州市| 闽侯县| 芒康县| 江门市| 建瓯市| 大田县| 长葛市| 临邑县| 中阳县| 东台市| 旺苍县| 黑山县| 衡阳县| 芦溪县| 托克托县| 清丰县| 上高县| 武城县| 东明县| 焦作市| 阳谷县| 莎车县| 六枝特区| 广州市| 藁城市| 长葛市| 阜康市| 平罗县| 溧水县| 德化县| 兰西县| 新津县| 怀柔区| 南安市| 浑源县| 陆川县| 清丰县| 姜堰市| 平凉市| 紫金县|