how to fill List(Of Type)?

六眼飞鱼酱① 提交于 2020-01-04 07:03:03

问题


I'm trying to validate a multidimensional array of inputs. I need to verify data types before they're sent to a prepared statement.

I'm making a Function that can be used to check data types of a multidimensional array received from a WebMethod ajax call, taking a multidimensional array as a parameter and a list of Types as another to check the columns against.

I'm trying to do, for example,

Dim columnTypes = New List(Of Type) from {Integer, Integer, String, String}

but Visual Studio 2010 keeps reporting '.' expected.

How can this be done properly?


回答1:


Type literals needs to be wrapped into GetType:

Dim columnTypes = New List(Of Type) From {GetType(Integer), GetType(Integer),
                                          GetType(String), GetType(String)}


来源:https://stackoverflow.com/questions/17557512/how-to-fill-listof-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!