?
Solved

Returning arraylist from a method

Posted on 2014-03-19
2
Medium Priority
?
224 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 2000 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

752 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