字符串加1
来源:互联网 发布:pplive网络电视直播 编辑:程序博客网 时间:2024/05/08 00:34
string strCode = "001001999";
string strChar = string.Empty;
string strRight, strMiddle, strLeft;
strRight = string.Empty;
strMiddle = string.Empty;
strLeft = string.Empty;
int j = 0;
strChar = string.IsNullOrEmpty(strCode) ? "001" : strCode;
if (strCode.Substring(strChar.Length - 1).Equals("9"))
{
for(int i=0; i < strCode.Length; i++)
{
if ( strCode.Substring((strCode.Length - i - 1),1).Equals("9"))
j++;
else
break;
}
strRight = strRight.PadRight(j, '0'); //有多少个9补多少个零
strMiddle = Convert.ToString(int.Parse(strCode.Substring(strCode.Length - j - 1, 1))+ 1); //加1后的值
strLeft = strCode.Substring(0, strCode.Length - j - 1); //
strChar = strLeft + strMiddle + strRight;
}
else
{
strRight = Convert.ToString(int.Parse(strCode.Substring(strCode.Length - 1)) + 1);
strLeft = strCode.Substring(0,strCode.Length - 1);
strChar = strLeft + strRight;
}
Response.Write(strChar);
- 字符串加1
- sql 字符串加1
- 字符串值自动加1
- 字符串自动加1,.net C#环境
- js 字符串转数字 加1
- 字符串的数字部分加1操作
- c 16进制 字符串 加一 c 16进制 字符串 加1 源代码
- 字符串的加解密
- base64字符串加水印
- 字符串之接加
- 字符串加解密
- 字符串加解密
- php字符串加解密
- 字符串加解密
- 字符串加解密
- 字符串加解密
- 字符串加解密
- 字符串加解密
- JavaScript加密解密7种方法
- 灰度图像转换为彩色
- 基本预防asp中木马的方法
- 从网页上下载文件
- 保存网页内容到txt
- 字符串加1
- 保存HTML页面源码至文件
- symbian解析XML学习之路(四)
- 调用保存对话框
- 3gp文件的parse
- 网站维护经验
- 将网页保存为Stream
- 一份电子工程师常用网站
- sql server行转列问题终极解决