Can I change it to vb.net list(of Date) to Date() OR ArrayList(of Date) to Date()?

Viewed 53

Can I change it to vb.net list(of Date) to Date() OR ArrayList(of Date) to Date() ?

Or is there a way to add it to Date() type like ArrayList.add ??

The variable we need now is of type Date().

1 Answers
Dim date_array as Date()
Dim date_list as New List(of Date)
date_list.Add(Date.Now)
date_array = date_list.ToArray()

if you use an ArrayList be sure to cast for specific type

Dim date_arraylist As New ArrayList
date_arraylist.Add(Date.Now)
date_array = date_arraylist.Cast(of Date)().ToArray()

if you want to add you need to resize

Array.Resize(date_array, date_array.Length + 1)
date_array(date_array.Length - 1) = Date.Now 'or date_list(x)
Related