Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm trying to create an object similar to a structure. Can't figure out how to do this

I want something like this: Buffer(4).Tray(10).Cell(99).SerialNumber = "test"

where Buffer is an object of the following classes

Class Tray

Class Cell


Thank your for your guidance
Posted
Comments
Sergey Alexandrovich Kryukov 9-Mar-15 12:54pm    
You did not really explain what you want to create.
—SA

The question is not clear. You can keep using arrays of objects instead of creating a type with the array syntax. Also, you can use collections of objects, such as System.Collections.Generic.List<>.
Also, you can create indexed property which implements access by index using array-like syntax:
https://www.informit.com/guides/content.aspx?g=dotnet&seqNum=149[^],
http://support.microsoft.com/kb/311323[^].

—SA
 
Share this answer
 
v3
Dear Sergey: thanks for the reply. I'm sorry that my questions is not clear.

Let me try to explain better.

I easily can create a structure and use REDIM to create the required array:

Something like this:

Public Class clsBufferClass
Public Structure Traydef
Dim ChipSerialNumber() As String
End Structure
End class

DIM Buffer(10) As clsBufferClass.BufferDef

For intI As Integer = 0 To 10
Buffer(intI) = New clsBufferClass.BufferDef
'Reallocate storage space for tray array
ReDim Buffer(intI).Tray(10)
For intJ As Integer = 0 To 10
'Reallocate storage space for chips serial number
ReDim Buffer(intI).Tray(intJ).ChipSerialNumber(99)
Next intJ
Next intI


Now, I can easily reference to a given buffer (4), tray (10) and chip (99).

Buffer(4).Tray(10).Cell(99).SerialNumber

I would like to create something similar using classes. With a class I could for example use INotifyPropertyChanged.

Any ideas? Thank you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900