获取队列内元素的索引c# [英] Get the index of an element inside queue c#

查看:16
本文介绍了获取队列内元素的索引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);

有什么想法吗?

谢谢

推荐答案

也许 ListArray 对于此类操作会更好,但你可以试试这个:

Maybe a List or an Array would be better for such actions but you could try this:

queue.ToArray().ToList().IndexOf(email);

这篇关于获取队列内元素的索引c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆