sonbinary
asked on
Problem Queue..!!!!!!
I have a queue with some items in it.....now I wan't to get these items to an array like this :
string[] a=myQueue.ToCharArray();
but it return an error....help me...!!!
string[] a=myQueue.ToCharArray();
but it return an error....help me...!!!
Quick way to do this might be:
Object[] testArray = myQueue.ToArray();
foreach(string s in testArray)
Debug.WriteLine(s);
HTH.
Razzie
Object[] testArray = myQueue.ToArray();
foreach(string s in testArray)
Debug.WriteLine(s);
HTH.
Razzie
Of course, this is when the items in the queue are of type string. If you have an other type in it, just cast them to the right type.
ASKER
the items in the queue is string ...so coding here, it have a problem....:
string[] a=(string[])myQueue.ToChar Array();
string[] a=(string[])myQueue.ToChar
What kind of collection are you using? The 'Queue' class does not have a method 'ToCharArray()'.
private void button1_Click(object sender, System.EventArgs e)
{
Queue myQueue = new Queue();
myQueue.Enqueue("a");
myQueue.Enqueue("b");
myQueue.Enqueue("c");
Object[] myArray = myQueue.ToArray();
MessageBox.Show(Convert.To String(myA rray[0])); /*Displays a*/
}
There is no ToCharArray for Queue. I hope the above code does what you want.
{
Queue myQueue = new Queue();
myQueue.Enqueue("a");
myQueue.Enqueue("b");
myQueue.Enqueue("c");
Object[] myArray = myQueue.ToArray();
MessageBox.Show(Convert.To
}
There is no ToCharArray for Queue. I hope the above code does what you want.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
sorry ToArray() is method of the Queue ..I'm sorry..
what type are the items in the Queue? I don't think Queue has a ToCharArray() method, but there'll be a way round it.
BCS