开发者

error message on a line of code

开发者 https://www.devze.com 2023-01-30 11:27 出处:网络
I am getting this error message: Warning 1 Variable declaration without an \'As\' clause; type of Object assumed.

I am getting this error message:

Warning 1 Variable declaration without an 'As' clause; type of Object assumed.

And here is the line of code tha开发者_如何学编程t generate the error message:

Dim acceptedExtensions = New String() {".jpg", ".png", ".gif"}

Can someone help me please?


Specify the type of your variable as String():

Dim acceptedExtensions As String() = New String() {".jpg", ".png", ".gif"}


Just use Option Infer, and the compiler will infer the type as String().

Option Infer On
...
Dim acceptedExtensions = New String() {".jpg", ".png", ".gif"}

The warning message indicates you have Option Strict Off. I definitely recommend always using Option Strict On to avoid all sorts of problems.

0

精彩评论

暂无评论...
验证码 换一张
取 消