让字符串中的数字加一,代码尽量简洁,快速字符串的格式统一为“F_数字”

解决方案 »

  1.   


    string oldStr="F_222";
    string newStr="F_"+(int.parse(oldStr.substring(2))+1).tostring();
      

  2.   

    string[] res;
    string src="F_222";
    res=src.split("_");
    src=res[0]+"_"+(++convert.toint32(res[1])).tostring();不知道对不对,自己试一下吧,
      

  3.   


                string str = "F_222";
                string[] strArray = str.Split(new char[] { '_' });
                int intNum = Convert.ToInt32(strArray[1]);
                intNum++;
                str = "F_" + intNum.ToString();
      

  4.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Text.RegularExpressions;namespace ConsoleCSharp
    {
        class Program
        {
            static void Main(string[] args)
            {
                string oldStr = "F_222";
                Console.WriteLine(oldStr.Substring(0,2)+(int.Parse(oldStr.Substring(oldStr.IndexOf('_')+1))+1).ToString());        }
        }
    }