Tangible Software Solutions

The Most Trusted Name in Source Code Conversion

C# Equivalent to Java ArrayList

The nearly exact C# (or VB) equivalent to Java's ArrayList collection is the .NET System.Collections.Generic.List collection.

Original Java:

void ArrayLists()
{
   java.util.ArrayList<Integer> myList = new java.util.ArrayList<Integer>();
   myList.add(1);
   myList.add(1, 2);
   int i = 1;
   myList.set(0, i);
   i = myList.get(0);
}

Equivalent C#:

using System.Collections.Generic;

void ArrayLists()
{
   List<int?> myList = new List<int?>();
   myList.Add(1);
   myList.Insert(1, 2);
   int i = 1;
   myList[0] = i;
   i = myList[0].Value;
}

If you need to convert from Java to C# and you are depending on the results being reliable and accurate, then you will want to have Java to C# Converter, the best Java to C# converter, at your fingertips.

Copyright © 1997 - 2017 Tangible Software Solutions Inc.