Get the index of an element inside queue c#(获取队列内元素的索引c#)
问题描述
我在 c# 中有一个用户队列(电子邮件字符串),我想向用户发送他在这个队列中的位置.
I have a queue of users(string of emails) a in c# and I want to send the user his location in this queue.
类似的东西;
Queue q = new Queue(32);
q.Enqueue(Session["email"].ToString());
queue.IndexOf(email);
有什么想法吗?
谢谢
推荐答案
也许 List
或 Array
对于此类操作会更好,但你可以试试这个:
Maybe a List
or an Array
would be better for such actions but you could try this:
queue.ToArray().ToList().IndexOf(email);
这篇关于获取队列内元素的索引c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!