16,552
社区成员
发帖
与我相关
我的任务
分享
Dim str As Object = "X"
Dim pt As New Point
'什么让pt.str就是pt.X
pt.X = 1 : pt.str = 1
'或者像是这样的
Dim pt As New Point
Dim str As Object = CType(pt & ".X", Point.X)
str = 1
'更者还有别的办法?!
Public Function FromMulArrayGetArrayf(pt() As Point, X As String) As Integer()
'.................
'.................
'.................
End Function
Dim pt(1) As Point
pt(0) = New Point(1, 2)
pt(1) = New Point(3, 4)
Dim PT_X_arr() As Integer
PT_X_arr = FromMulArrayGetArrayf(pt, "X")
'结果是:
'PT_X_arr {Length = 2} Integer()
'(0) 1 Integer
'(1) 3 Integer
这样的功能又得什么最优获取,我可能这几天代码写太多了头晕想不出来!
Imports System.Runtime.InteropServices
Public Function FromMulArrayGetArray(MulArray(,) As Integer, 维数 As Integer)
Dim GetArray(MulArray.GetUpperBound(MulArray.Rank - 1)) As Integer
Dim FirstAddress As IntPtr = Marshal.UnsafeAddrOfPinnedArrayElement _
(MulArray, GetArray.Length * 维数)
Marshal.Copy(FirstAddress, GetArray, 0, GetArray.Length)
Return GetArray
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim MArr(2, 0) As Integer '第2维是0,下面应该是{{14}, {24}, {34}}才对这TM是个BUG!
'试验过后大小是以MArr(0, *)来定义的也就是{14, 13, 12, 11, 10}那么后面的两维也得是5上参数
MArr = {{14, 13, 12, 11}, {24, 23, 22, 21}, {34, 33, 32, 31}}
Dim arr() As Integer
arr = FromMulArrayGetArray(MArr, 1)
'结果是:
'arr {Length = 4} Integer()
'(0) 24 Integer
'(1) 23 Integer
'(2) 22 Integer
'(3) 21 Integer
End Sub
Public Class Form1
Public Structure pt
Public x As String
Public y As String
End Structure
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim p As New pt
p.x = "x"
p.y = "y"
End Sub
End Class