怎么把字符串中的内容当一个表达式或程序中的一行用。
比如
1、string s="this.Close()"
怎么 s 执行 this.Close();在比如
2、 var bindingSource1=from p in DB.Clinet where id==111||id==222||id==333 select p
有如下的方法实现2、的效果
string str="id==111||id==222||id==333 "; //用一定的方法实现str
var bindingSource1=from p in DB.Clinet where str p //怎么让str 实现 2、的效果
比如
1、string s="this.Close()"
怎么 s 执行 this.Close();在比如
2、 var bindingSource1=from p in DB.Clinet where id==111||id==222||id==333 select p
有如下的方法实现2、的效果
string str="id==111||id==222||id==333 "; //用一定的方法实现str
var bindingSource1=from p in DB.Clinet where str p //怎么让str 实现 2、的效果
static void Main()
{
// Data source
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; // Create the query with a method call in the where clause.
// Note: This won't work in LINQ to SQL unless you have a
// stored procedure that is mapped to a method by this name.
var queryEvenNums =
from num in numbers
where IsEven(num)
select num; // Execute the query.
foreach (var s in queryEvenNums)
{
Console.Write(s.ToString() + " ");
}
} // Method may be instance method or static method.
static bool IsEven(int i)
{
return i % 2 == 0;
}
}
//Output: 4 8 6 2 0
那个高人知道,用那个.net的可以做 到比较2个 字符串数组 str_Arr1、str_Arr2 如果有1个字符串相同就返回真,没有返回假。
bindingSource1.DataSource = from p in DB_ClientInfo.ClientInfo where str_Arr.Contains (p.TypeId ) select p;