Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下字符串模式
string str = "MCHH-1-00001";
我需要在每次页面加载之前检查 00001 值并将其增加“1”,请告诉我如何做到这一点。
如果第一部分是静态的:
string identifier = "MCHH-1-"; int num = int.Parse(str.Substring(identifier.Length)); str = identifier + (++num).ToString("D5");
演示
你能试试这个
string[] value= str.Split('-');
并获得像
string numericValue=value[2];