开发者

error message on a line of code

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜