Reputation:
Orginnally I had a BlockingCollection
BlockingCollection<ChannelResource> ChannelQueue = new BlockingCollection<ChannelResource>();
I added the items to it.
ChannelResource ChanResource = TelephonyServer.GetChannel();
MyApplication.ChannelQueue.TryAdd(ChanResource);
Now I find that each ChannelResource has a corresponding string, so I want to add ChannelResource object with the string together to the BlockingCollection.
How? Merge the object ChannelResource and the string to form an anonymous type?
EDIT:
I mean do I have to redifine the BlockingCollection as
BlockingCollection<T> ChannelQueue = new BlockingCollection<T>();
And T contains ChannelResource
and string
together?
Upvotes: 0
Views: 626
Reputation: 3921
I suppose that you can use the Tuple
class (http://msdn.microsoft.com/en-us/library/system.tuple.aspx), like this:
var ChannelQueue = new BlockingCollection<Tuple<ChannelResource, String>>();
ChannelResource ChanResource = TelephonyServer.GetChannel();
MyApplication.ChannelQueue.TryAdd(Tuple.Create(ChanResource, "someString"));
Upvotes: 2