Casting in visual basic?

前端 未结 5 1562
情书的邮戳
情书的邮戳 2020-12-16 16:26

I\'m a C# programmer who is forced to use VB (eh!!!!). I want to check multiple controls state in one method, in C# this would be accomplished like so:

if ((         


        
5条回答
  •  [愿得一人]
    2020-12-16 17:06

    DirectCast will perform the conversion at compile time but can only be used to cast reference types. Ctype will perform the conversion at run time (slower than converting at compile time) but is obviously useful for convertng value types. In your case "sender" is a reference type so DirectCast would be the way to go.

提交回复
热议问题