繁体   English   中英

将带有空格分隔符的字符串转换为uint16

[英]Convert string with space separators to uint16

嗨,我需要帮助将字符串转换为uint16数组

我的字符串看起来像:

Dim test as String = "4 7 9 10 11 12 14 15 16 17 19 23 24 25 26 27 28 29 30 32 33 37 40 42 48 58 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79"

我需要将其转换为类中的属性

Public Property BiosCharacteristics As UInt16()

我已经试过了:

Dim test As String = xdoc.GetAttribute(xnitem, "biosCharacteristics")
Dim stringSeparators() As String = {" "}

.BiosCharacteristics = test.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries)

我可以为每个对象做一个寻找空白“”,但我正在寻找一种更复杂的方法。

谢谢!

使用LINQ

.BiosCharacteristics = (From s In test.Split(" "c) Select UInt16.Parse(s)).ToArray()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM