位运算包含功能
2012-03-21 21:14 yuejianjun 阅读(449) 评论(0) 编辑 收藏 举报 public class 位运算包含功能
{
public static void IsContains()
{
int intSubClassID = 0;
int intClassid = 0;
int[] main = new int[] {3,5,7,8,9 };
for (int i = 0; i < main.Length; i++)
{
intClassid = 1 << main[i];
intSubClassID |= intClassid;
}
int qa = 25;
qa = GetBit(qa);
if ((intSubClassID & qa) != qa)
{
///不包含
Console.WriteLine("不包含" );
}
else
{
///包含
Console.WriteLine("包含");
}
}
private static int GetBit(int sum)
{
int i = 1 << sum;
return i;
}
}
{
public static void IsContains()
{
int intSubClassID = 0;
int intClassid = 0;
int[] main = new int[] {3,5,7,8,9 };
for (int i = 0; i < main.Length; i++)
{
intClassid = 1 << main[i];
intSubClassID |= intClassid;
}
int qa = 25;
qa = GetBit(qa);
if ((intSubClassID & qa) != qa)
{
///不包含
Console.WriteLine("不包含" );
}
else
{
///包含
Console.WriteLine("包含");
}
}
private static int GetBit(int sum)
{
int i = 1 << sum;
return i;
}
}