gpt4 book ai didi

c# - 将 lambda 字符串表达式转换为 Func 错误 : "No property or field ' v' exists in type 'String' "

转载 作者:行者123 更新时间:2023-11-30 14:05:42 25 4
gpt4 key购买 nike

我想将字符串 lambda 表达式转换为 Func,但出现以下错误:“类型‘String’中不存在属性或字段‘v’”。

var func = System.Linq.Dynamic.DynamicExpression.ParseLambda<string, string>("v => v.ToLower()").Compile();

var outputValue = func(inputValue);

最佳答案

参数是隐式的,叫做it:

var func = System.Linq.Dynamic.DynamicExpression.ParseLambda<string, string>(
"it.ToLower()").Compile();

这个事实似乎没有记录,但假设这是 System.Linq.Dynamic ,请注意,尽管有 System.* 命名空间,但它不是似乎是 Microsoft 拥有的库。

关于c# - 将 lambda 字符串表达式转换为 Func<string, string> 错误 : "No property or field ' v' exists in type 'String' ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54555204/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com