我如何在vb.net中声明像php这样的变量

时间:2013-06-07 05:46:05

标签: vb.net

PHP:

if(($a = $toto) == 'test') echo $a;

VB.net

Dim a as string = toto
if a.equals("test") then console.writeline(a)

我喜欢“一线”代码设计,那么,是否有可能在vb.net中做到这一点?

2 个答案:

答案 0 :(得分:2)

这将是多行而不是

    Dim a As String = "test"
    Dim b As String = a

    if (b.equals("test")) then  console.writeline(b) 

或者亚历山大建议你可以使用这样的一个衬垫(实际上编译器实际上不是一个衬垫)

    Dim a As String = "test", b As String = a

    if (b.equals("test")) then  console.writeline(b) 

答案 1 :(得分:0)

您可以使用以下内容......

我还没有这样做,但我希望它能帮到你..

Option Explicit Off

Public Class Form1


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)       Handles Button1.Click
        If ((ss = "test") = "test") Then MessageBox.Show("hi")
    End Sub
End Class
相关问题