Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent Dictionary #25

Open
Rai-a opened this issue Apr 7, 2018 · 1 comment
Open

Inconsistent Dictionary #25

Rai-a opened this issue Apr 7, 2018 · 1 comment
Assignees
Labels

Comments

@Rai-a
Copy link

Rai-a commented Apr 7, 2018

using System;
using System.Collections.Generic;

public class Class1
{
    public static void Main(string[] args)
    {
        Dictionary<Class1, Class1> state1 = new Dictionary<Class1, Class1>();
        state1.Add(new Class1(), new Class1());
        foreach (Class1 key in state1.Keys)
            Console.Write(state1[key]);
        Dictionary<Class1, Class1> state2 = state1.Copy();
        foreach (Class1 key in state2.Keys)
            Console.Write(state2[key]);//Exception
    }
}

Occurs for all Dictionarys who use classes as key that do not override GetHashCode()

@Burtsev-Alexey Burtsev-Alexey self-assigned this May 7, 2018
@jpmikkers
Copy link

This is a tricky one, the only way to solve this is by filling a new Dictionary with the cloned keys and values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants