0

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?

svick
  • 236,525
  • 50
  • 385
  • 514
  • What do you want to achieve? It is not very clear what is the target of that. – Mare Infinitus Apr 29 '14 at 13:33
  • Please gave a reason for down vote. –  Apr 29 '14 at 14:14
  • I did not downvote. I never did, as can be seen in my badges. – Mare Infinitus Apr 29 '14 at 14:29
  • @MareInfinitus That's just sad. Not downvoting poor quality content when you see it is very detrimental to the site. Downvotes serve a very important purpose. – Servy Apr 29 '14 at 20:06
  • @Servy There is always the possibility to flag, which is less demotivating, as most of the time somebody who writes wants to help. And of course, there should always be a comment first, before a downvote. – Mare Infinitus Apr 29 '14 at 20:36
  • @MareInfinitus The majority of posts that should be downvoted (which is a *lot* of them) don't warrant flagging. Posts that need to be flagged make up a fairly small portion of bad posts. If a post is so bad that you feel the need to flag it then it almost certainly meets the criteria for downvoting, and should therefore be downvoted. And no, a comment is *not* mandatory when downvoting. In fact, such comments are less likely to be helpful than harmful. So few people are able to accept constructive criticism; you're *far* more likely to just get into a fight than to actually help someone. – Servy Apr 29 '14 at 20:37
  • @Servy You are right. Of course every flag can be a downvote. But I still believe that a comment helps more than a downvote. Uncommented downvotes just lead to more low quality posts that get more downvotes. Perhaps that discussion would be better on meta. – Mare Infinitus Apr 29 '14 at 20:41
  • @Servy You are right. I had some of those discussions already. And after most of them I felt like I just lost time. Perhaps I have to rethink my voting strategy. – Mare Infinitus Apr 29 '14 at 20:44
  • @MareInfinitus It's possible, but very unusual, for such comments to add value. Downvotes on bad posts are adding value the majority of the time. Even if it doesn't help the author, it helps the site to get rid of or hide the low quality content. Users that really want to improve generally will, with or without our help (and when a really enthusiastic user comes along they virtually always get lots of help); those that won't, won't be helped no matter how much you comment. – Servy Apr 29 '14 at 20:45

1 Answers1

2

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"));
Andrei Bozantan
  • 3,781
  • 2
  • 30
  • 40