如何将STRING转换为INT,反之亦然? [英] How to convert STRING to INT and vice versa?
本文介绍了如何将STRING转换为INT,反之亦然?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
那里有程序员!
我很难说这个。我的文本框中有一个字符串(milestone_code),我希望得到该字符串以添加另一个字母,其中的数字将添加为5.它应该是这样的:
BOO-45 -----> BOO-CC-50
任何人都可以帮助我!我希望你理解我的问题:)
Hi programmers there!
I am having a hard time about this one. I have a string in my textbox (milestone_code) and I want to get that string to add another letters to it and the numbers to it will be added by 5. It should be like this:
BOO-45 -----> BOO-CC-50
Can anyone can help me please! I hope you understand my question :)
推荐答案
string input ="BOO-45";
string[] parts = input.Split('-');
int number =Int32.Parse(parts[1]) +5;
string result = parts[0] + "-CC-" +number.ToString();
参考:
Int32.Parse方法 [ ^ ]
C#Split [ ^ ]
这篇关于如何将STRING转换为INT,反之亦然?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文