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

BizTalk Server 2013 Azure VM Log Shipping and HA for hosts

Azure DocumentDB Owner resource does not exist

SQL Server 2008 - High Memory Usage