Arrays 将带空格分隔符的字符串转换为uint16
您好,我需要帮助将字符串转换为uint16数组 我的字符串看起来像:Arrays 将带空格分隔符的字符串转换为uint16,arrays,vb.net,string,transform,uint16,Arrays,Vb.net,String,Transform,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 = "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)
我可以为每一个都做一个测试,并寻找空的空间“”,但我正在寻找一种更复杂的方法
谢谢 使用:
.BiosCharacteristics = (From s In test.Split(" "c) Select UInt16.Parse(s)).ToArray()