我正在使用SyntaxWalker浏览树,在下面的函数中,我意识到我需要在我正在处理之前插入一个语句。
Public Overrides Function VisitDeclarationExpression(ByVal Node As CSS.DeclarationExpressionSyntax) As VisualBasicSyntaxNode
Dim VariableDesignation As CSS.SingleVariableDesignationSyntax = CType(Node.Designation, CSS.SingleVariableDesignationSyntax)
Dim name As NameColonEqualsSyntax = Nothing
Dim value As ExpressionSyntax = CType(VariableDesignation.Accept(Me), ExpressionSyntax)
' Need to Insert Dim before the statement that contains this SimpleArgument
Return SyntaxFactory.SimpleArgument(name, value)
End Function
我需要声明“name = Nothing”,所以我可以在TryGetValue(name)中使用name。在C#中使用
很容易return v.TryGetValue(out var name)
但在VB中我需要两个语句
Dim name As Object = Nothing
Return v.TryGetValue(name)
如何将Dim插入到我正在走路的声明之上?