我有一个字符串“201607”,我需要将它拆分为 2 个不同的类型。 2016 成 int,07 成 byte。我见过字符串拆分函数,它们都使用定界符,但在这里不起作用。有没有更简单的方法来执行此操作,或者我必须将其拆分为字符,然后在 C# 中重建它们?
最佳答案
也试试看:
string input="201607";
int IntPart=Convert.ToInt32(input.Substring(0,4));
byte BytePart=Convert.ToByte(input.Substring(4));
关于c# - 如何将 String 拆分为 2 种不同的类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38987645/