Solved

Passing class derived from ArrayList

Posted on 2004-10-20
2
218 Views
Last Modified: 2010-05-18
my class "List", is derived from "ArrayList".

I have a function, "foo" that accepts an "ArrayList" as a parameter.


foo(ref ArrayList al)
{
...
}


I want to pass an object of type "List" to foo:


foo(ref List )


but when i cast it, it says it needs to be an lvalue, because its a ref.


What should i be doing?

TIA.
0
Comment
Question by:dave_p_r_b
2 Comments
 
LVL 1

Accepted Solution

by:
gav_jackson earned 125 total points
ID: 12356253
you just pass the list object directly into foo (it will be a reference type anyway as it is an arraylist)

foo(List myList)
{
  //myList does not need to be cast as its already a "List" object
}


or am i totally missing the point?
0
 

Author Comment

by:dave_p_r_b
ID: 12356286
No, youve hit the point spot on.

Thanks for your help!

For anyone else, I found an article on msdn that explains  "Passing Reference types by value" .

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vclrfPassingMethodParameters.asp
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Diagnostics with Net and Net.Sockets 2 32
Video Player 2017 5 35
VB.NET (2008) - Refactoring Question 2 24
VB: Convert 2 dates to specific format 24 52
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question