locked
do we have lists with mapping in c# RRS feed

  • Question

  • i've a scenario,

    in a chat application i'm storing every opened chat windows in a list and when a user sends instant i want to check if chat window for corresponding user is alive or not.

    for now i'm checking this using for loop checking each windows if it have the same user,

    do we have any thing in c# through which i can map chat windows  using username?

    I'm talking about something treemap or hashmap of java.

    Please reply


    Regards Kumar Gaurav.
    Monday, October 24, 2011 4:28 PM

Answers

  • Dictionary<string,WhateverYourClassNameIs>

     

    • Proposed as answer by Reed Copsey, JrMVP Monday, October 24, 2011 6:33 PM
    • Marked as answer by urprob Wednesday, October 26, 2011 7:12 AM
    Monday, October 24, 2011 4:42 PM
  • Hi urprob,

    For example, if your current List is like:
    List<ChatWindow>.
    You could promote it using Dictionary<TKey, TValue>: http://msdn.microsoft.com/en-us/library/xfhwa508.aspx as below:
    Dictionary<userNameString, ChatWindow>
    or if the ChatWindow class has a property which stores the user name, you could use like this:
    Dictionary<ChatWindow.UserName, ChatWindow>.

    Have a nice day,


    Leo Liu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Woohoooo Tuesday, October 25, 2011 11:50 AM
    • Marked as answer by urprob Wednesday, October 26, 2011 7:12 AM
    Tuesday, October 25, 2011 11:38 AM

All replies

  • Dictionary<string,WhateverYourClassNameIs>

     

    • Proposed as answer by Reed Copsey, JrMVP Monday, October 24, 2011 6:33 PM
    • Marked as answer by urprob Wednesday, October 26, 2011 7:12 AM
    Monday, October 24, 2011 4:42 PM
  • Hi urprob,

    For example, if your current List is like:
    List<ChatWindow>.
    You could promote it using Dictionary<TKey, TValue>: http://msdn.microsoft.com/en-us/library/xfhwa508.aspx as below:
    Dictionary<userNameString, ChatWindow>
    or if the ChatWindow class has a property which stores the user name, you could use like this:
    Dictionary<ChatWindow.UserName, ChatWindow>.

    Have a nice day,


    Leo Liu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Woohoooo Tuesday, October 25, 2011 11:50 AM
    • Marked as answer by urprob Wednesday, October 26, 2011 7:12 AM
    Tuesday, October 25, 2011 11:38 AM