字母序列递增,即A+1=B,B+2=D,ASCII
2015-12-19 21:09
211 查看
实际遇到的问题是 单号15001订单的15001-A自动生成15001-B,15001-C....
//说明:以15001-A为基准生成15001-B string maxno ="15001-A"; //1.把订单号和后缀分隔开 string[] strmax = maxno.Split('-');//以‘-’分割字符串,把150001和A分开 //2.转换ASCII码值需要字符串为char型,转换之 char sort = (char)strmax[1][0];//strmax[1]为数组第2个元素,strmax[1][0]为数组第2个元素的第一个字符 //3.转换为ASCII对应的数字 int ascii = (int)sort;//字母A转换为ASCII值65 //4.序号+1 int ascii2 = ascii + 1;//序号加1,为66 //5.转换回字母 string sort2 = ((char)ascii2).ToString(); //再转换为字母B //6.返回拼接后的字符串15001-B return strmax[0] + "-" + sort2.ToString();
相关文章推荐
- 大神眼中的React Native--备用
- 不要沦陷程序员30岁问题
- HAProxy 安装与配置
- Shell脚本
- Java中九大内置对象
- android:activity知识点
- 近期code review几处小问题集锦
- python 开发工具搭建
- LeetCode 3Sum Closest
- System.Data.OracleClient requires Oracle client software version 8.1.7 or greater.
- 点击一个按钮触发文件选择
- AngularJS 表格
- 数独(九宫格)的高效算法
- wine下玩魔兽的设置
- 如何将办公文件转换成图片(一) -- 搭建Windows环境下OpenOffice+mupdf+vs2013的开发环境
- JsplitPane
- 安装mysql过程中卡在starting server解决办法
- js从数组中删除指定值(不是指定位置)的元素
- C语言回顾 学习进程
- 生产应用常见坑