博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C# String 前面不足位数补零的方法
阅读量:4708 次
发布时间:2019-06-10

本文共 343 字,大约阅读时间需要 1 分钟。

在 C# 中可以对字符串使用 PadLeft 和 PadRight 进行轻松地补位。

       PadLeft(int totalWidth, char paddingChar) //在字符串左边用 paddingChar 补足 totalWidth 长度

       PadRight(int totalWidth, char paddingChar) //在字符串右边用 paddingChar 补足 totalWidth 长度

eg:Pznm =(snode.InnerText).ToString().PadLeft(10,'0');

       字符串固定为10位,不足10位左边补零。

转载于:https://www.cnblogs.com/Stillwatersrundeep/p/6774487.html

你可能感兴趣的文章
HDU-1085 Holding Bin-Laden Captive-母函数
查看>>
php提示undefined index的几种解决方法
查看>>
LRJ
查看>>
Struts2环境搭建
查看>>
Linux: Check version info
查看>>
stl学习之测试stlen,cout等的运行速度
查看>>
魔戒三曲,黑暗散去;人皇加冕,光明归来
查看>>
Error和Exception
查看>>
Python和Singleton (单件)模式[转载]
查看>>
httpclient设置proxy与proxyselector
查看>>
IT常用单词
查看>>
拓扑排序
查看>>
NYOJ--32--SEARCH--组合数
查看>>
gulpfile 压缩模板
查看>>
【34.14%】【BZOJ 3110】 [Zjoi2013]K大数查询
查看>>
【 henuacm2016级暑期训练-动态规划专题 A 】Cards
查看>>
第五篇:白话tornado源码之褪去模板的外衣
查看>>
设备常用框架framework
查看>>
bootstrap模态框和select2合用时input无法获取焦点(转)
查看>>
MockObject
查看>>