//----找到集合中的交集,并在第一个参数中出去交集部分
enum em
{
one = 0,
two = 2,
three = 4,
four = 8,
five = 16,
six=32
}
private void MainFun()
{
int a = Convert.ToInt32(em.one | em.two | em.five|em.six);
int b = Convert.ToInt32(em.one | em.three | em.two | em.four);
var x = GetSingle(a, b);
}
/// <summary>
/// 去除交集的预算
/// </summary>
/// <param name="a">要去除交集的</param>
/// <param name="b">母集合</param>
/// <returns></returns>
private int GetSingle(int a, int b)
{
if ((a & b) <= 0)
return a ;
int m = a & b;
return GetSingle(a - m, b);
}
enum em
{
one = 0,
two = 2,
three = 4,
four = 8,
five = 16,
six=32
}
private void MainFun()
{
int a = Convert.ToInt32(em.one | em.two | em.five|em.six);
int b = Convert.ToInt32(em.one | em.three | em.two | em.four);
var x = GetSingle(a, b);
}
/// <summary>
/// 去除交集的预算
/// </summary>
/// <param name="a">要去除交集的</param>
/// <param name="b">母集合</param>
/// <returns></returns>
private int GetSingle(int a, int b)
{
if ((a & b) <= 0)
return a ;
int m = a & b;
return GetSingle(a - m, b);
}