简体   繁体   English

我可以将它更改为 vb.net list(of Date) to Date() 或 ArrayList(of Date) to Date()?

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

Can I change it to vb.net list(of Date) to Date() OR ArrayList(of Date) to Date()?我可以将它更改为 vb.net list(of Date) to Date() 或 ArrayList(of Date) to Date()?

Or is there a way to add it to Date() type like ArrayList.add??或者有没有办法将它添加到像 ArrayList.add 这样的 Date() 类型?

The variable we need now is of type Date().我们现在需要的变量是 Date() 类型的。

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如果您使用 ArrayList 一定要为特定类型投射

Dim date_arraylist As New ArrayList
date_arraylist.Add(Date.Now)
date_array = date_list.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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM