mercredi 4 février 2015

Expressionparameter not defined correctly

I'm working with reflection in VB.net I try to format a date to a string with 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)


But I've error message :



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



I try before :



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


It's first time I use Expressionparameter. It seems to me I'm following to rigth path. But With the error, I think I don't understand sometthing.


Thanks for helping






Aucun commentaire:

Enregistrer un commentaire