Array of structure

L

Leon

Hi Everybody

I have a small structure
Structure SkuInfo
Dim SkuNo As String
Dim Priority As Integer
End Structure
and Array

Dim arrSkus() As SkuInfo

Before adding next element to this array I want to make sure
that I do not have elements with the same SKUNO.

I am trying to use indexof, but do not know how to use it with array of
structures.
I realize I can use For... Next loop, but hope there is a better way to do
this.

Thanks in advance
 
L

Leon

Thank you Mark.
I'll try that.

Mark Rae said:
Firstly, I would not use an array for this. Instead, I'd use a Dictionary
generic. Generics were introduced in .NET Framework v2, and are many times
more powerful and function-rich than arrays. A Dictionary would allow you to
add the structure *and* reference it by its SkuNo:
http://msdn.microsoft.com/en-us/library/xfhwa508.aspx

http://msdn.microsoft.com/en-us/library/kw5aaea4.aspx


Alternatively, you could use (probably) use LINQ to query the array:
http://www.google.co.uk/search?rlz=...28&aq=f&sourceid=chrome&ie=UTF-8&q=LINQ+array

However, the generic method will be much simpler, and probably much
faster...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top