I have a Dictionary. I use this code to get the index of the object:
type.Name = _shuffledClasses.Where(entry => entry.Key.Name.Equals(originName))
.Where(entry => entry.Key.Namespace.Equals(type.Namespace))
.Select(item => item.Value).GetEnumerator().Current.Name;
But it doesn't find the Object. I double checked if the Object is create correctly and if it exists, and it does! The Object in question is in the 'Key' column and I wan't to get the object in the 'Value' column.
I tried also this piece of code, which doesn't work aswell:
type.Name = _shuffledClasses[new Classes()
{
Name = originName,
Namespace = type.Namespace
}].Name;
My "Classes" Object looks as follows:
class Classes
{
public string Namespace { get; set; }
public string Name { get; set; }
}
Why wont it find the Object?
I did some research and I tried overriding Equals and GetHashCode, now my class looks like this and still doesn't work:
public override bool Equals(object obj)
{
Classes fooItem = obj as Classes;
return fooItem == this;
}
public override int GetHashCode()
{
return base.GetHashCode();
}