0

There is anyway to gives the queue id name? (0,1,2 and so on):

foreach (var item in FirstLineKeyValuePairs)
{

    Queue *name* = new Queue());

}

i want the give name to the new Queue().

Ballon Ura
  • 882
  • 1
  • 13
  • 36
  • 4
    It's likely you want to have an array of `Queue`s if you want to assign a number to them. – Rob Dec 09 '16 at 09:43
  • 5
    The real question is why do you care about that ? What is the problem all of the queue in the loop to have same name ? What is the real problem which you are facing. – mybirthname Dec 09 '16 at 09:44
  • 1
    I think he is looking for something like "dynamic variable naming" what was answered here: http://stackoverflow.com/questions/20857773/create-dynamic-variable-name – TripleEEE Dec 09 '16 at 09:48

1 Answers1

0

You can easily achieve this with an array or a list of queues:

var queues = new List<Queue>();
foreach (var item in FirstLineKeyValuePairs)
{    
    queues.Add(new Queue());
}

Now you can access them by an index:

var q1 = queues[0];

This is not the exact thing you want, but usually you don´t care for variable-names and want only access the data of any variable. You don´t need its "name" for that as shown above.

MakePeaceGreatAgain
  • 35,491
  • 6
  • 60
  • 111
  • maybe he wants to work with `nameof()` for exception handling or something - that's the situation I heard that question mostly – TripleEEE Dec 09 '16 at 09:56