public Dictionary <long, long> ApplyMask(string mask, int address, string value)
            {
                string          reverseMask = new string(mask.Reverse().ToArray());
                BitArray        orMask      = new BitArray(reverseMask.Replace('X', '0').Select(x => x == '1').ToArray());
                BitArray        bitValue    = BitArrayHelper.GetBitArrayFor(address, orMask.Length);
                BitArray        orValue     = new BitArray(bitValue).Or(orMask);
                BitArray        xMask       = new BitArray(reverseMask.Replace('1', '0').Replace('X', '1').Select(x => x == '1').ToArray());
                List <BitArray> addresses   = new List <BitArray> {
                    orValue
                };

                for (int index = 0; index < xMask.Length; index++)
                {
                    if (xMask[index])
                    {
                        List <BitArray> testList = addresses.ToList();
                        foreach (BitArray currentAddress in testList)
                        {
                            currentAddress.Set(index, false);
                            BitArray newAddress = new BitArray(currentAddress);
                            newAddress.Set(index, true);
                            addresses.Add(newAddress);
                        }
                    }
                }
                long newValue = long.Parse(value);
                Dictionary <long, long> result = new Dictionary <long, long>();

                addresses.ForEach(x => result.Add(
                                      key: BitArrayHelper.GetBitArrayValue(x),
                                      value: newValue
                                      ));
                return(result);
            }
            public Dictionary <long, long> ApplyMask(string mask, int address, string value)
            {
                string   reverseMask           = new string(mask.Reverse().ToArray());
                BitArray andMask               = new BitArray(reverseMask.Replace('X', '1').Select(x => x == '1').ToArray());
                BitArray orMask                = new BitArray(reverseMask.Replace('X', '0').Select(x => x == '1').ToArray());
                BitArray bitValue              = BitArrayHelper.GetBitArrayFor(int.Parse(value), andMask.Length);
                Dictionary <long, long> result = new Dictionary <long, long>();

                result.Add(address, BitArrayHelper.GetBitArrayValue(bitValue.Or(orMask).And(andMask)));
                return(result);
            }