doubt

N

nallamalah

how to decalre arraylists in csharp
i gave it like this iam getting error
using System;
using System.Collections;
public class aldemo
{
static void Main()
{
Arraylist al=new Arraylist;
al.add("v1");
al.add("v2");
al.add("v3");
Console.WriteLine(al[2]);
}
}

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
M

Morten Wennevik

Hi Haritha,

The ArrayList stores object references of everything you put inside.
You will have to cast it back to its original type.

object o = al[2];
string s = (string)o;

or

Console.WriteLine((string)al[2]);
 
S

Shiva

It is ArrayList, not Arraylist (note the char-casing). Also, () should be
present after the ArrayList (when declared using new keyword) as in:
ArrayList al = new ArrayList();

HTH.

how to decalre arraylists in csharp
i gave it like this iam getting error
using System;
using System.Collections;
public class aldemo
{
static void Main()
{
Arraylist al=new Arraylist;
al.add("v1");
al.add("v2");
al.add("v3");
Console.WriteLine(al[2]);
}
}

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET
resources...
 
G

Guest

Hi haritha,

try this
Arraylist al=new Arraylist();
you skipped the brackets

regards
Ansil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top