What can I use in place of a "long" that could be cloneable?
Refer below to the code for which I'm getting an error here as long is not cloneable.
public static CloneableDictionary<string, long> returnValues = new CloneableDictionary<string, long>();
EDIT: I forgot to mention I was wanting to use the following code that I found (see below).
public class CloneableDictionary<TKey, TValue> : Dictionary<TKey, TValue> where TValue : ICloneable
{
public IDictionary<TKey, TValue> Clone()
{
var clone = new CloneableDictionary<TKey, TValue>();
foreach (KeyValuePair<TKey, TValue> pair in this)
{
clone.Add(pair.Key, (TValue)pair.Value.Clone());
}
return clone;
}
}
There is no point in cloning a long
.
You should use a regular Dictionary<string, long>
.
If you want to clone the dictionary itself, you can write new Dictionary<string, long>(otherDictionary)
.