To get a shallow copy, just use the constructor of Dictionary<TKey, TValue>
as it takes an IEnumerable<KeyValuePair<TKey, TValue>>
. It will add this collection into the new instance.
Dictionary<int, int> flagsn = new Dictionary<int, int>(flags);