A
A. Burch
Is it legal to pass a generic object as a parameter, like the following
function is trying to do Queue<int>q. Please see the URL with the entire
example and can someone tell me why this doesn't compile and how to fix it:
private static void ShowQueueContents(Queue<int> q)
{
lock (((ICollection)q).SyncRoot)
{
foreach (int item in q)
{
Console.Write("{0} ", item);
}
}
Console.WriteLine();
}
The example below for a producer/consumer doesn't compile with VS 2005
correctly.
http://msdn2.microsoft.com/en-us/library/yy12yx1f.aspx
function is trying to do Queue<int>q. Please see the URL with the entire
example and can someone tell me why this doesn't compile and how to fix it:
private static void ShowQueueContents(Queue<int> q)
{
lock (((ICollection)q).SyncRoot)
{
foreach (int item in q)
{
Console.Write("{0} ", item);
}
}
Console.WriteLine();
}
The example below for a producer/consumer doesn't compile with VS 2005
correctly.
http://msdn2.microsoft.com/en-us/library/yy12yx1f.aspx