清除自定义数组 [英] Clearing a custom array

查看:62
本文介绍了清除自定义数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

而不是ZeroMemory API在VB.NET中使用什么来使用自定义结构来清理数组?


.clear isn' '默认是它的成员。


有什么建议吗?


谢谢,

亚当

Instead of the ZeroMemory API what would one use in VB.NET to
clean an array using a custom structure?

The .clear isn''t a member of it by default.

Any suggestions?

Thanks,
Adam

推荐答案

" Adam Honek" <广告******* @ Webmaster2001.freeserve.co.uk> schrieb:
"Adam Honek" <Ad*******@Webmaster2001.freeserve.co.uk> schrieb:
而不是ZeroMemory API在VB.NET中使用什么来使用自定义结构清理数组?

.clear isn''默认为ta成员。
Instead of the ZeroMemory API what would one use in VB.NET to
clean an array using a custom structure?

The .clear isn''t a member of it by default.




究竟什么不起作用?


\\\

私人结构测试

公共名称为字符串

公共号码为整数


Public Sub New(_

ByVal Name As String,_

ByVal Number As Integer _



Me.Name = Name

Me.Number =数字

结束次级

结束结构

....

Dim a()As Test = _

{_

New Test(Hello,12),New Test(Bla,2)_ < br $>
}

Array.Clear(a,0,a.Length)

///


-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps.org/>

VB <的URL:http://classicvb.org/petitio n />



What exactly is not working?

\\\
Private Structure Test
Public Name As String
Public Number As Integer

Public Sub New( _
ByVal Name As String, _
ByVal Number As Integer _
)
Me.Name = Name
Me.Number = Number
End Sub
End Structure
....
Dim a() As Test = _
{ _
New Test("Hello", 12), New Test("Bla", 2) _
}
Array.Clear(a, 0, a.Length)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


嗯,


它不是VB.NET阵列。


这是一个结构(VB6类型),因此被放入一个数组:


结构HelloWorld

dim消息为字符串

暗日期为字符串

结束结构


public Lets尝试HellowWorld()


它将编译如下,但在尝试运行该代码时会失败:


''在我们开始填写电子邮件帐户数组之前,请确保它很好

和清洁

Array.Clear(LetsTry,0,LetsTry.Length)


我想这是因为我是没有做{}数组格式你的例子

显示。


亚当


" Herfried K.瓦格纳[MVP]" <喜*************** @ gmx.at>在消息中写道

news:ut ************** @ TK2MSFTNGP03.phx.gbl ...
Hmmm,

It''s not a VB.NET array.

It''s a structure (VB6 Type) that gets put into an array hence:

Structure HelloWorld
dim Message as string
dim date as string
end structure

public LetsTry as HellowWorld()

It will compile as below but fall over when it tries to run that code:

''Before we start filling the email accounts array lets make sure it''s nice
and clean
Array.Clear(LetsTry, 0, LetsTry.Length)

I guess it''s because I''m not doing the {} array format your example below
shows.

Adam

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ut**************@TK2MSFTNGP03.phx.gbl...
" Adam Honek" <广告******* @ Webmaster2001.freeserve.co.uk> schrieb:
"Adam Honek" <Ad*******@Webmaster2001.freeserve.co.uk> schrieb:
而不是ZeroMemory API在VB.NET中使用什么来使用自定义结构清理数组?

.clear isn''默认是ta成员。
Instead of the ZeroMemory API what would one use in VB.NET to
clean an array using a custom structure?

The .clear isn''t a member of it by default.



究竟什么不起作用?

\\\
私人结构测试
公共名称为字符串
公共号码为整数

Public Sub New(_
ByVal Name As String,_
ByVal Number As Integer _
)< br。> Me.Name =姓名
Me.Number =数字
结束子
结束结构
...
Dim a()As Test = _
{_
新测试(Hello,12),新测试(Bla,2)_
}
Array.Clear(a,0,a.Length )
///

- MS Herfried K. Wagner
MVP< URL:http://dotnet.mvps.org/>
VB< URL:http://classicvb.org/petition/>



What exactly is not working?

\\\
Private Structure Test
Public Name As String
Public Number As Integer

Public Sub New( _
ByVal Name As String, _
ByVal Number As Integer _
)
Me.Name = Name
Me.Number = Number
End Sub
End Structure
...
Dim a() As Test = _
{ _
New Test("Hello", 12), New Test("Bla", 2) _
}
Array.Clear(a, 0, a.Length)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>



当我尝试dec把它称为新它简单地说数组不能用

来表示新。关键词。


Adam


" Herfried K. Wagner [MVP]" <喜*************** @ gmx.at>在消息中写道

news:ut ************** @ TK2MSFTNGP03.phx.gbl ...
When I try declare it as "New" it simply says arrays cannot be delcared with
the "New" keyword.

Adam

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ut**************@TK2MSFTNGP03.phx.gbl...
" Adam Honek" <广告******* @ Webmaster2001.freeserve.co.uk> schrieb:
"Adam Honek" <Ad*******@Webmaster2001.freeserve.co.uk> schrieb:
而不是ZeroMemory API在VB.NET中使用什么来使用自定义结构清理数组?

.clear isn''默认是ta成员。
Instead of the ZeroMemory API what would one use in VB.NET to
clean an array using a custom structure?

The .clear isn''t a member of it by default.



究竟什么不起作用?

\\\
私人结构测试
公共名称为字符串
公共号码为整数

Public Sub New(_
ByVal Name As String,_
ByVal Number As Integer _
)< br。> Me.Name =姓名
Me.Number =数字
结束子
结束结构
...
Dim a()As Test = _
{_
新测试(Hello,12),新测试(Bla,2)_
}
Array.Clear(a,0,a.Length )
///

- MS Herfried K. Wagner
MVP< URL:http://dotnet.mvps.org/>
VB< URL:http://classicvb.org/petition/>



What exactly is not working?

\\\
Private Structure Test
Public Name As String
Public Number As Integer

Public Sub New( _
ByVal Name As String, _
ByVal Number As Integer _
)
Me.Name = Name
Me.Number = Number
End Sub
End Structure
...
Dim a() As Test = _
{ _
New Test("Hello", 12), New Test("Bla", 2) _
}
Array.Clear(a, 0, a.Length)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>



这篇关于清除自定义数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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