如何在字符串中使用循环表达式并使用? [英] How to Take For loop Expression in String and Use?
本文介绍了如何在字符串中使用循环表达式并使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
if (DGRightOption.Items.Count > DGLeftOption.Items.Count)
{
loop = "for (int i = 0; i < DGRightOption.Items.Count; i++)";
}
else
{
loop = "for (int i = 0; i < ObjDatagrid.Items.Count; i++)";
}
推荐答案
此在.NET中动态执行代码 [ ^ ]文章是很好地按照你想要的方式解释事物。我建议详细阅读,做一些实验,然后解决你的问题。
This Dynamically Executing Code in .NET[^] article is great in explaining things the way you want. I suggest to read it in detail, do some experimentation and then come to your problem.
int max;
if (DGRightOption.Items.Count > DGLeftOption.Items.Count)
{
max = DGRightOption.Items.Count;
}
else
{
max = ObjDatagrid.Items.Count;
}
for (int i = 0; i < max; i++)
{
// code here
}
这篇关于如何在字符串中使用循环表达式并使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文