Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8980749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:09:51+00:00 2026-06-15T20:09:51+00:00

I have a C# ArrayList with objects that includes following fields. I have around

  • 0

I have a C# ArrayList with objects that includes following fields. I have around 10 objects in the ArrayList. My problem is I need to sort the ArrayList based on the StartDate available in the system which is a DateTime variable.

public int id { get; set; }
public string title {get; set;}
public bool allDay { get; set; }
public string start { get; set; }
public string end { get; set; }
public string color { get; set; }
public DateTime startDate { get; set; }
public DateTime endDate { get; set; }
public string Location { get; set; }
public string StartDatestr { get; set; }
public string EndDatestr { get; set; }
public string StartTime { get; set; }
public string EndTime { get; set; }
public bool Alert { get; set; }
public bool Repeat { get; set; }
public Int32 RepeatDays { get; set; }
public Int32 CalendarID { get; set; }
public int CustomerNo { get; set; }
public string CustomerName { get; set; }
public bool IsProspect { get; set; }
public string Description { get; set; }

Can someone please enlighten me? I tried .Sort() but it just doesn’t do anything (its dump to try sort on ArrayList which has objects I know).

Thanks in advance.

Update:

List<Appointment> appointments = new List<Appointment>();

I created the List as above. Now can I sort it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:09:52+00:00Added an answer on June 15, 2026 at 8:09 pm

    Try by creating comparere like as below

    public class ComparerDateTime : IComparer
    {
        public int Compare(object x, object y)
        {
            MYCLASS X = x as MYCLASS;
            MYCLASS Y = y as MYCLASS;
    
            return X.date.CompareTo(Y.date);
        }
    }
    
     MYCLASSList.Sort(new ComparerDateTime ());
    

    OR

    Create Generic collection than you can do this

    give try to Enumerable.OrderBy operation will do work for you..you need to include linq for this

    IEnumerable<Pet> query = arrayList .OrderBy(x=> x.startDate );
    

    if list is created like as below than try linq option

    List<MYCLASS> arrayList  = new List<MYCLASS>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ArrayList that I want to use to hold RaceCar objects that
I have an ArrayList of objects in one activity and I need this arrayList
I have an ArrayList containing Objects that have a date value. Now I want
I have an ArrayList of objects that have a name and an icon pointer
In Eclipse, I see that ArrayList objects have a modCount field. What is its
I have an ArrayList of Objects(POJOs) that have an Id and another field. I
I have an ArrayList. It will have duplicate objects in that arraylist. The duplicate
I have an ArrayList with custom objects that I would like to be able
I have an ArrayList that is getting objects that contain user information from a
I have an arraylist of objects that I want to create all possible combinations

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.