8,494
社区成员




a => a.tdIsDelete != true && a.uStatus >= 0 && ((a.uLoginName != null && a.uLoginName.Contains(key)) || (a.uRealName != null && a.uRealName.Contains(key)))
a => a.tdIsDelete != true && a.uStatus >= 0 && ((a.uLoginName != null && a.uLoginName.Contains(key)))
using System;
using System.Linq;
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
//生成个随机数组
Random rnd = new Random(Environment.TickCount);
int[] test = Enumerable.Range(1, 10).OrderBy(i => rnd.Next()).ToArray();
//文本,类似读取的配置
string string_from_config_or_other = "客户A要求";
//根据配置选择委托指向的方法
Func< int, bool> condition = null;
if (string_from_config_or_other == "客户A要求")
{
condition = TrueCondition;
}
else
{
condition = FalseCondition;
}
//执行linq
int[] result = test.OrderBy(i => condition(i)).ToArray();
result.ToList().ForEach(i => Console.Write(i.ToString() + ","));
}
static bool TrueCondition(int a)
{
return a > 5;
}
static bool FalseCondition(int a)
{
return a <= 5;
}
}
}