Use the Constructor that takes a Dictionary. See this example
var dict = new Dictionary<string, string>();
dict.Add("SO", "StackOverflow");
var secondDict = new Dictionary<string, string>(dict);
dict = null;
Console.WriteLine(secondDict["SO"]);
And just for fun.. You can use LINQ! Which is a bit more Generic approach.
var secondDict = (from x in dict
select x).ToDictionary(x => x.Key, x => x.Value);
Edit
This should work well with Reference Types, I tried the following:
internal class User
{
public int Id { get; set; }
public string Name { get; set; }
public User Parent { get; set; }
}
And the modified code from above
var dict = new Dictionary<string, User>();
dict.Add("First", new User
{ Id = 1, Name = "Filip Ekberg", Parent = null });
dict.Add("Second", new User
{ Id = 2, Name = "Test test", Parent = dict["First"] });
var secondDict = (from x in dict
select x).ToDictionary(x => x.Key, x => x.Value);
dict.Clear();
dict = null;
Console.WriteLine(secondDict["First"].Name);
Which outputs "Filip Ekberg".