Solved

Returning arraylist from a method

Posted on 2014-03-19
2
217 Views
Last Modified: 2014-03-19
Hi there,

in VB.Net we can write a function which returns arraylist. How we do this in C# as it seems no option to do this. for example i want this to achieve

Public ArrayList MyMethod(string a)
{
}

regards,
0
Comment
Question by:shah36
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 39939229
The below should be perfectly valid.
public ArrayList MethodName(string a)
{
}

Open in new window

You may need to add a using statement for the System.Collections namespace, if you don't have one already, as newer Studios only tend to include the one for generics by default.
using System.Collections;

Open in new window

Or you can use the expanded:
public System.Collections.ArrayList MethodName(string a)
{
}

Open in new window

You may also want to consider using one of the newer Generics (List<> for example) rather than ArrayList.
0
 

Author Closing Comment

by:shah36
ID: 39939232
Ah thanks a lot. yes including the system.collection name space resolved it. Thanks again
regards,
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

861 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now