Hi Kumas1281,
I would recommand you to use a generic list<t> instead of ArrayList.
Please refer below sample code.
Namespaces
C#
using System.Collections.Generic;
using System.Linq;
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
List<Customer> customers = new List<Customer>();
customers.Add(new Customer() { CustomerId = 1, Name = "Robert Schidner", Country = "Russia" });
customers.Add(new Customer() { CustomerId = 2, Name = "Mudassar Khan", Country = "India" });
customers.Add(new Customer() { CustomerId = 3, Name = "Suzanne Mathews", Country = "France" });
customers.Add(new Customer() { CustomerId = 4, Name = "John Hammond", Country = "United States" });
Array customerArray = customers.OrderBy(x => x.Name).ThenBy(x => x.Country).ToArray();
}
public class Customer
{
public int CustomerId { get; set; }
public string Name { get; set; }
public string Country { get; set; }
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim customers As List(Of Customer) = New List(Of Customer)()
customers.Add(New Customer() With {
.CustomerId = 1,
.Name = "Robert Schidner",
.Country = "Russia"
})
customers.Add(New Customer() With {
.CustomerId = 2,
.Name = "Mudassar Khan",
.Country = "India"
})
customers.Add(New Customer() With {
.CustomerId = 3,
.Name = "Suzanne Mathews",
.Country = "France"
})
customers.Add(New Customer() With {
.CustomerId = 4,
.Name = "John Hammond",
.Country = "United States"
})
Dim customerArray As Array = customers.OrderBy(Function(x) x.Name).ThenBy(Function(x) x.Country).ToArray()
End Sub
Public Class Customer
Public Property CustomerId As Integer
Public Property Name As String
Public Property Country As String
End Class