Funny little pop quiz


 

you have use vb this, thought quite fun, can guess does?

 

dim bla as object = cdate("2001-12-11")

console.writeline(bla.tostring("yyyy-mm-dd"))

 

 

 

......

 

did guess it?.....

 

 

{"conversion string "yyyy-mm-dd" type 'integer' not valid."}

 

 

(sorry if it's obvious suprised me).

 

 

 

 

it caused leak in vb.net syntax.  parentheses can both used method call , index array or string.  , parentheses optional if method doesn't take arguments.  that's lethal combination in case.  compiler parses follows:

        dim v object = cdate("2001-12-11")
        dim s string = v.tostring
        dim integer = cint("yyyy-mm-dd")
        dim t string = s(i)
        console.writeline(t)

it cint() call generates exception.  still sounds compiler bug, console.writeline() method required.  can report @ connect web site.


.NET Framework  >  Common Language Runtime Internals and Architecture



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'