vb.net从数组中删除第一个元素 [英] vb.net remove first element from array

查看:227
本文介绍了vb.net从数组中删除第一个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个答案是创建一个新的数组,该数组要短一个元素.还有其他更简单的方法吗?

One answer is to create a new array that is one element shorter. Are there any other simpler ways to do this?

推荐答案

这里是在vb.net中删除数组的第一个元素的一种方法.

Here is one way to remove the first element of an array in vb.net.

dim a(n)
...
for i = 1 to ubound(a)
  a(i-1) = a(i)
  next i
redim preserve a(ubound(a)-1)

您可以为此创建一个函数,以删除数组的任意元素(具有用于for循环的初始值的参数).

You could make a function for this to remove an arbitrary element of an array (Have a parameter for the initial value of the for loop).

这篇关于vb.net从数组中删除第一个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆