且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

LINQ 表达式转换/从 Int 到字符串的 Concat

更新时间:2023-11-07 19:13:34

您可以尝试转换为对象,然后调用 ToString(),而不是尝试转换为字符串:

Instead of trying to cast to string, you could try casting to object then calling ToString(), as though you were doing:

var converted = member.ToString();

作为一个表达式,它看起来像这样:

As an Expression, it will look something like this:

var convertedExpression = Expression.Call(
                     Expression.Convert(memberExpression, typeof(object)),
                     typeof(object).GetMethod("ToString"));