473,385 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Collection of classes

When create an array of type some class I can access the class method this
way:

Dim AccClass(1234) as SampleClass
arrClass(i).ClassMethod

Is the same possible with ArrayList or other type of Collection?

Thanks in advance
Nov 21 '05 #1
3 1017
well, you can do this

CType(myList(i), SampleClass).ClassMethod

or at least define:

Function SampleClassItem(index as integer) as SampleClass
return CType(myList(index), SampleClass)
End Function

and then you can use:

SampleClassItem(i).ClassMethod

Best Regards,
Alejandro Lapeyre
"Nikolay Petrov" <jo**************@mail.bg> escribió en el mensaje
news:%2****************@TK2MSFTNGP12.phx.gbl...
When create an array of type some class I can access the class method this
way:

Dim AccClass(1234) as SampleClass
arrClass(i).ClassMethod

Is the same possible with ArrayList or other type of Collection?

Thanks in advance

Nov 21 '05 #2
Any drawbacks of using - CType(myList(i), SampleClass).ClassMethod ?

"alejandro lapeyre" <al**************@spamhotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
well, you can do this

CType(myList(i), SampleClass).ClassMethod

or at least define:

Function SampleClassItem(index as integer) as SampleClass
return CType(myList(index), SampleClass)
End Function

and then you can use:

SampleClassItem(i).ClassMethod

Best Regards,
Alejandro Lapeyre
"Nikolay Petrov" <jo**************@mail.bg> escribió en el mensaje
news:%2****************@TK2MSFTNGP12.phx.gbl...
When create an array of type some class I can access the class method this
way:

Dim AccClass(1234) as SampleClass
arrClass(i).ClassMethod

Is the same possible with ArrayList or other type of Collection?

Thanks in advance

Nov 21 '05 #3
I would use DirectCast instead of CType. I believe it's somewhat faster.

"Nikolay Petrov" wrote:
Any drawbacks of using - CType(myList(i), SampleClass).ClassMethod ?

"alejandro lapeyre" <al**************@spamhotmail.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
well, you can do this

CType(myList(i), SampleClass).ClassMethod

or at least define:

Function SampleClassItem(index as integer) as SampleClass
return CType(myList(index), SampleClass)
End Function

and then you can use:

SampleClassItem(i).ClassMethod

Best Regards,
Alejandro Lapeyre
"Nikolay Petrov" <jo**************@mail.bg> escribió en el mensaje
news:%2****************@TK2MSFTNGP12.phx.gbl...
When create an array of type some class I can access the class method this
way:

Dim AccClass(1234) as SampleClass
arrClass(i).ClassMethod

Is the same possible with ArrayList or other type of Collection?

Thanks in advance


Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: downwitch | last post by:
Hi, I know this has been covered here and in the .public groups, but it seems like it's been a while, especially around here, so I just thought I'd ask again to see if anyone has figured out a...
11
by: Pavils Jurjans | last post by:
Hello, There's some confusion about the purpose and difference between these handy classes... First, both of them are holding number of key - value pairs, right? Then, I see that there may be...
2
by: Robert W. | last post by:
I'm trying to write a utility that will use Reflection to examine any data model I pass it and correctly map out this model into a tree structure. When I say "any" , in fact there will only be 3...
2
by: Edward Diener | last post by:
In C++ an overridden virtual function in a derived class must have the exact same signature of the function which is overridden in the base class, except for the return type which may return a...
2
by: Brian | last post by:
NOTE ALSO POSTED IN microsoft.public.dotnet.framework.aspnet.buildingcontrols I have solved most of my Server Control Collection property issues. I wrote an HTML page that describes all of the...
16
by: Ben Hannon | last post by:
Hi, I'm writting a COM Class in VB.NET to be used in a VB6 project (Tired of the VB6 hassles with cloning and serializing an object). All my classes I need cloneable/serializable are now in a...
4
by: Andrew | last post by:
I need to have a series of collection classes that inherit (I think) from each other. What is the best way to do this in .NET? In VB6 I had a series of collection classes each passing a reference...
3
by: Dave | last post by:
Please - anyone that can help. I am getting confusing results while trying to expose a collection from a web service. I have a webservice in which a web method accepts a collection as a...
19
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the...
7
by: =?Utf-8?B?Q29kZVJhem9y?= | last post by:
Can someone explain a few things about collections to me. In C# 2 generics, you can create a collection class by inheriting from System.Collections.ObjectModel.Collection. Using this you can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.