未正确定义表达式参数

Expressionparameter not defined correctly

我正在 VB.net 中使用反射 我尝试使用 fortmat

将日期格式化为字符串

yyyy MM dd

Dim FormatDte As String = "yyyy MM dd"
Dim d1 As Date = Now
Dim ttt1 = d1.ToString(FormatDte) 'It's good

Dim s1 As ParameterExpression = Expression.Parameter(GetType(String), "FormatDte")
toStr = Expression.Call(If(pinfo.PropertyType.IsValueType, Expr, Expression.Constant(Date.MinValue)), "ToString", Nothing, s1)

但是我有错误信息:

the variable 'FormatDte' of type 'System.String' is referenced from the scope '', but it is not defined

我之前试过:

Dim s1 As ParameterExpression = Expression.Parameter(GetType(String), "FormatDte")

第一次使用表达式参数。在我看来,我正在走正确的道路。但是由于错误,我想我有点不明白。

感谢您的帮助

抱歉...我只是觉得混合几个尝试

toStr = Expression.Call(Expr, "ToString", Nothing, Expression.Constant("yyyy MM dd"))