通过引用传递条件? [英] Passing a condition by reference?

查看:66
本文介绍了通过引用传递条件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过以下条件:

string condition = "dt.Rows[x][y].ToString()";


对我的功能:

private object[] CheckRows(string condition) ...


我怎样才能将字符串转换回Visual可以理解的地方?

一种可能是改写使用委托的方法,特别是使用 Funct<t,> [ ^ ].

另一种方法是使用反射和动态代码执行来实现魔术. CP和Google上有很多此类代码的示例.

这两种方法都可能会引起其他问题.希望对您有所帮助.

干杯.


I want to pass a condition like:

string condition = "dt.Rows[x][y].ToString()";


to my function:

private object[] CheckRows(string condition) ...


How can I convert that string back where Visual can understand it ?

解决方案

There are two interesting answers if you''re willing to work at it a little bit.

One would be to rephrase your approach to make use of delegates, particularly forming a predicate syntax using Funct<t,>[^].

The other would be to use reflection and dynamic code execution to make the magic happen. There are plenty of examples of such code here on CP and on Google.

Both those approaches will likely warrant additional questions. Hope this helps some.

Cheers.


这篇关于通过引用传递条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆