本文介绍了如何将对象数组转换为双数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个字符串,我想使用正则表达式来挑选值。我需要将生成的匹配集合传输到数组并将数据类型更改为Double。我遇到的挑战是将对象数组转换为双数组。这可能吗?如果是的话,我该如何去做?
Imports System.Text.RegularExpressions
Dim ValStr As String
ValStr = 0 = 1,1 = 4,2 = 3,3 = 2,4 = 7
Dim pattern As String =([0-9] +)(?= \,)|([0 -9] + $)
Dim re As New Regex(模式)
Dim mc As MatchCollection
Dim mcArr()As Object
Dim ValArr()As Double
mc = re.Matches(ValStr)
ReDim mcArr(mc.Count-1)
mc.CopyTo(mcArr,0)
是否有代码可以将mcArr的元素转换为Double并存储为新的Double数组?
解决方案
I have a string that I want to pick off values using a regular expression. I need to transfer the resulting match collection to an array and change the data type to Double. The challenge I am having is converting an Object Array to a Double Array. Is this possible? If it is, how would I go about doing it?
Imports System.Text.RegularExpressions Dim ValStr As String ValStr = "0=1,1=4,2=3,3=2,4=7" Dim pattern As String = "([0-9]+)(?=\,)|([0-9]+$)" Dim re As New Regex(pattern) Dim mc As MatchCollection Dim mcArr() As Object Dim ValArr() As Double mc = re.Matches(ValStr) ReDim mcArr(mc.Count-1) mc.CopyTo(mcArr,0)
Is there code I can put here to convert the elements of mcArr to Double and store as a new Double Array?
解决方案
这篇关于如何将对象数组转换为双数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!