![](/img/trans.png)
[英]Expression.Constant(value, type) type is unknown. How to define the type
[英]How to use Expression.Constant(object value, Type type)?
我在使用ConstantExpression
類時遇到問題:
Expression exp = Expression.Constant("1", typeof(Int32));
從上面執行代碼時,會拋出以下錯誤。
參數類型不匹配
如何使用Constant(object value, Type type)
方法?
您傳遞了一個字符串,表示1
,而只是使用沒有雙引號的數字:
Expression exp = Expression.Constant(1, typeof(Int32));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.