VB.NET里有没有与with功能相近的替代方法?

2026-05-06 12:261阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计331个文字,预计阅读时间需要2分钟。

VB.NET里有没有与with功能相近的替代方法?

我持续使用相同的功能,是否可行 + with basicmove(r), (u, 20), (r) end with 替换 basicmove(r) basicmove(u, 20) basicmove(r) 编辑:或 basicmove(l, 5) basicmove(d, 3) basicmove(l, 21) basicmove(u, 5) 我不确定这会否解

我连续使用相同的功能,有没有办法

with basicmove() {(r),(u, 20),(r) end with

代替

basicmove(r) basicmove(u, 20) basicmove(r)

编辑:或

VB.NET里有没有与with功能相近的替代方法?

basicmove(l, 5) basicmove(d, 3) basicmove(l, 21) basicmove(u, 5) 我不完全确定这会解决你要求的所有问题,但也许它会给你一个想法.

编辑:根据更新的问题,我有另一种解决方案.这需要在编程中理解two-dimensional arrays.您只需将所有“坐标”加载到一个数组中,然后迭代它们并按照它们输入到数组中的相同顺序执行操作.

Sub Main() ' multi-dimensional array of moves (there are plenty of way to create this object if this is confusing) Dim myList(,) As Object = New Object(,) { _ {"l", 5}, _ {"d", 3}, _ {"l", 21}, _ {"u", 5} _ } ' iterate the array and perform the moves. For x As Integer = 0 To myList.GetUpperBound(0) ' getting coordinates from the first & second dimension basicmove(myList(x, 0), myList(x, 1)) Next Console.ReadLine() End Sub Private Sub basicmove(ByVal a As String, ByVal b As Integer) Console.WriteLine("param1:" & a & ",param2:" & b) End Sub

本文共计331个文字,预计阅读时间需要2分钟。

VB.NET里有没有与with功能相近的替代方法?

我持续使用相同的功能,是否可行 + with basicmove(r), (u, 20), (r) end with 替换 basicmove(r) basicmove(u, 20) basicmove(r) 编辑:或 basicmove(l, 5) basicmove(d, 3) basicmove(l, 21) basicmove(u, 5) 我不确定这会否解

我连续使用相同的功能,有没有办法

with basicmove() {(r),(u, 20),(r) end with

代替

basicmove(r) basicmove(u, 20) basicmove(r)

编辑:或

VB.NET里有没有与with功能相近的替代方法?

basicmove(l, 5) basicmove(d, 3) basicmove(l, 21) basicmove(u, 5) 我不完全确定这会解决你要求的所有问题,但也许它会给你一个想法.

编辑:根据更新的问题,我有另一种解决方案.这需要在编程中理解two-dimensional arrays.您只需将所有“坐标”加载到一个数组中,然后迭代它们并按照它们输入到数组中的相同顺序执行操作.

Sub Main() ' multi-dimensional array of moves (there are plenty of way to create this object if this is confusing) Dim myList(,) As Object = New Object(,) { _ {"l", 5}, _ {"d", 3}, _ {"l", 21}, _ {"u", 5} _ } ' iterate the array and perform the moves. For x As Integer = 0 To myList.GetUpperBound(0) ' getting coordinates from the first & second dimension basicmove(myList(x, 0), myList(x, 1)) Next Console.ReadLine() End Sub Private Sub basicmove(ByVal a As String, ByVal b As Integer) Console.WriteLine("param1:" & a & ",param2:" & b) End Sub