Hello
I am using a Dictionary to store some queues which store instances of a class
that I have written
I would like to be able to determine whether a particular queue already contains
an instance with a particular value
Here is the code
using System;
using System.Collections.Generic;
namespace AlexanderWalker.Scratch
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
public static void Main()
{
Dictionary<int, Queue<A>> queueDictionary = new Dictionary<int,
Queue<A>>();
Queue<A> aQueue = new Queue<A>();
queueDictionary.Add(1, aQueue);
A aInstance1 = new A();
aInstance1.B = 5;
queueDictionary[1].Enqueue(aInstance1);
A aInstance2 = new A();
aInstance2.B = 5;
if (queueDictionary[1].Contains(aInstance2))
Console.WriteLine("Found instance of A with B set to 5");
else
Console.WriteLine("Nothing was found");
}
class A
{
private int b;
public int B
{
get
{
return b;
}
set
{
b = value;
}
}
}
}
}
In the code above I would like to alter the class A or inherit from the queue so
that the text "Found instance of a with B set to 5" would be displayed on the
console. How would I do this?
Thanks
Alex