Check object is in layermask unity

C#
public bool IsInLayerMask(GameObject obj, LayerMask layerMask)
{
	return ((layerMask.value & (1 << obj.layer)) > 0);
}
Source

Also in C#: