string[] arr = { "BH0001", "BH0003", "BH0005" }; var result = (from s in arr select Regex.Match(s, @"\d+").Value.TrimStart('0')).ToArray(); foreach (string s in result) { Console.WriteLine(s); } 1 3 5 循环判断
string[] arr = { "BH0001", "BH0003", "BH0005" }; string[] arr = { "BH0001", "BH0003", "BH0006" };var result = (from s in arr select Regex.Match(s, @"\d+").Value.TrimStart('0')).ToArray(); foreach (string s in result) { Console.WriteLine……
with codes as(select 'BH0001' as code union all select 'BH0002' union all select 'BH0003' union all select 'BH0004' union all select 'BH0005') select code from codes where not exists(select 1 from codeTable where codeTable.code=codes.code);就是生成全部的信息有点困难。
存储过程中游标遍历
或循环,截取数字,判断是否连续list.Contains判断
var result = (from s in arr select Regex.Match(s, @"\d+").Value.TrimStart('0')).ToArray();
foreach (string s in result)
{
Console.WriteLine(s);
}
1
3
5
循环判断
string[] arr = { "BH0001", "BH0003", "BH0006" };var result = (from s in arr select Regex.Match(s, @"\d+").Value.TrimStart('0')).ToArray();
foreach (string s in result)
{
Console.WriteLine……
select 'BH0004' union all select 'BH0005')
select code from codes where not exists(select 1 from codeTable where codeTable.code=codes.code);就是生成全部的信息有点困难。
string s2 = "BH010"; int change = 3; //字符串变化的位数 string s3 = s1.Substring(0, s1.Length - change); //截取字母部分 Console.WriteLine(s1); //循环次数
int count = (int.Parse(s2.Substring(s2.Length - change)))
- (int.Parse(s1.Substring(s1.Length - change))); for (int i = 0; i < count; i++)
{
int temp = int.Parse(s1.Substring(s1.Length - change)) + 1; //变成整数并加一
s1 = s3 + temp.ToString().PadLeft(change, '0'); //生成新字符串
Console.WriteLine(s1);
}
Console.ReadLine();