我正在使用C#.NET和Windows CE Compact Framework。我有一个代码,它应该将一个字符串分隔成两个文本框。如何将一个字符串分为两个字符串
textbox1 = ID
textbox2 = quantity
string BarcodeValue= "+0000010901321 JN061704Z00";
textbox1.text = BarcodeValue.Remove(0, BarcodeValue.Length - BarcodeValue.IndexOf(' ') + 2);
//Output: JN061704Z00
textbox2.text = BarcodeValue.Remove(10, 0).TrimStart('+').TrimStart('0');
//Output: should be 1090 but I am getting a wrong output: 10901321 JN061704Z00
//Please take note that 1090 can be any number, can be 999990 or 90 or 1
有人可以帮助我吗? :((
谢谢!
使用Split函数 – Roar
什么是“错误的输出”你得到;另外,我怀疑你得到JN061704X00 - 因为输入没有X –
@MarcGravell应该是Z而不是X,已经编辑它。谢谢! – QKWS