using System.Collections.Generic;
public class ValueTranslation<T>
public string Text { get; set; }
public T Value { get; set; }
public static void Main()
Type t = typeof(Program.Sample);
var fields = t.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Static);
var val = fields[0].GetValue(null);
var name = fields[0].Name;
List<ValueTranslation<BitMask>> list = new List<ValueTranslation<BitMask>>();
list.Add(new ValueTranslation<BitMask>
Console.WriteLine("Hello World "+ list[0].Value);
public static class Sample
public static readonly BitMask ViewApvWellBeingDepartmentCompareReport = new BitMask(0x0000000000200000, 3);
public BitMask(ulong value, int bank)
public static implicit operator ulong(BitMask b)
public static BitMask operator &(BitMask a, BitMask b)
return new BitMask(a._value & b._value, a._bank);
public static BitMask operator |(BitMask a, BitMask b)
return new BitMask(a._value | b._value, a._bank);
public static BitMask operator ^(BitMask a, BitMask b)
return new BitMask(a._value ^ b._value, b._bank);
public static bool operator ==(BitMask a, BitMask b)
public static bool operator !=(BitMask a, BitMask b)
public bool Equals(BitMask rhs)
return (_value == rhs._value) && (_bank == rhs._bank);
public override bool Equals(object obj)
return Equals((BitMask)obj);
public override int GetHashCode()
return ToString().GetHashCode();
public override string ToString()
return string.Concat(_bank, "_", _value);
public IEnumerable<BitMask> GetConstituents()
for (int i = 0; i < 64; i++)
yield return new BitMask(l, _bank);
public IEnumerable<string> GetValueList()
for (int i = 0; i < 64; i++)
yield return l.ToString();
public static BitMask Parse(string s)
if (string.IsNullOrEmpty(s))
var tokens = s.Split('_');
throw new FormatException("The string is not in b format parsable as an BitMask");
BitMask b = new BitMask();
if (!int.TryParse(tokens[0], out b._bank))
throw new FormatException("The string is not in b format parsable as an BitMask");
if (!ulong.TryParse(tokens[1], out b._value))
throw new FormatException("The string is not in b format parsable as an BitMask");
private static void AssertBankMatch(BitMask a, BitMask b)
throw new InvalidOperationException("Cannot operate on BitMasks in different banks");
public static readonly BitMask Empty = new BitMask(0, -1);