DataTable Compute ?
System.Data.DataTable dt = new System.Data.DataTable();
string str = "0001";
string _str = dt.Compute(str + "+1", null).ToString().PadLeft(4, '0');
System.Data.DataTable dt = new System.Data.DataTable();
string str = "0001";
string _str = dt.Compute(str + "+1", null).ToString().PadLeft(4, '0');
string tempValue = "0001"; // 001
string result = "";
int length = tempValue.Length;
int value1 = Convert.ToInt32(tempValue);
value1++;
result = value1.ToString().PadLeft(length == 4 ? 4 : 3, '0');
修改下,没有判断是否为NULL就是了,需要的话,自己改动下
SELECT RIGHT(POWER(10,LEN(ID)) + ISNULL(CAST(ID AS INT),0)+1,LEN(ID)) FROM TEST
string s = "0011";
string s2 = ((int.Parse(s) + 100001).ToString()).Substring(6 - s.Length, s.Length);