Solved

Returning arraylist from a method

Posted on 2014-03-19
2
220 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

749 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