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
Solved

Returning arraylist from a method

Posted on 2014-03-19
2
219 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

789 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