Time values in arraylist
-
Hi i want to have time in arraylist like following 9:45 AM 10:00 AM 10:15 AM 10:30 AM .... so basically 15 mins are added to previous item.. How to do this? Pls reply ASAP.
-
Hi i want to have time in arraylist like following 9:45 AM 10:00 AM 10:15 AM 10:30 AM .... so basically 15 mins are added to previous item.. How to do this? Pls reply ASAP.
Member 3981366 wrote:
Pls reply ASAP.
This is more likely to stop people from replying. Everybody here is a volunteer, if your problem is that urgent, then get your credit card out and go to rentacoder.com. Firstly, try not to use
ArrayList
, useList
instead. It is type safe and more efficient. Look it up in the documentation for further details. Something like:List timeList = new List(); DateTime startTime = new DateTime(1, 1, 1, 9, 0, 0); DateTime endTime = new DateTime(1, 1, 1, 18, 0, 0); while (startTime <= endTime) { timeList.Add(startTime); startTime.AddMinutes(15); }
would work.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
Hi i want to have time in arraylist like following 9:45 AM 10:00 AM 10:15 AM 10:30 AM .... so basically 15 mins are added to previous item.. How to do this? Pls reply ASAP.
What will you do with it? Depending on what you plan to do, you may not actually need to store all that in memory. Here's an enumerator from my TimeRanger[^] article:
public static System.Collections.Generic.IEnumerable<System.DateTime> MinuteEnumerator ( System.DateTime StartPoint , System.DateTime EndPoint , ushort SteppingFactor ) { System.DateTime current = PIEBALD.Lib.LibTim.DateTruncate ( StartPoint , PIEBALD.Lib.LibTim.TimeGranularity.Minute ) ; if ( StartPoint <= EndPoint ) { if ( current < StartPoint ) { current = current.AddMinutes ( 1 ) ; } while ( current <= EndPoint ) { yield return ( current ) ; current = current.AddMinutes ( SteppingFactor ) ; } } else { while ( current >= EndPoint ) { yield return ( current ) ; current = current.AddMinutes ( SteppingFactor\*-1 ) ; } } yield break ; }
Or you could use this to load a List if you really want to store the information.
-
Member 3981366 wrote:
Pls reply ASAP.
This is more likely to stop people from replying. Everybody here is a volunteer, if your problem is that urgent, then get your credit card out and go to rentacoder.com. Firstly, try not to use
ArrayList
, useList
instead. It is type safe and more efficient. Look it up in the documentation for further details. Something like:List timeList = new List(); DateTime startTime = new DateTime(1, 1, 1, 9, 0, 0); DateTime endTime = new DateTime(1, 1, 1, 18, 0, 0); while (startTime <= endTime) { timeList.Add(startTime); startTime.AddMinutes(15); }
would work.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
To me, "ASAP" means the same as "when you can get around to it".