I’m trying to keep a timer for users in my IRC. When a user types a message I’m trying to insert the username & time of the message. This is to stop spammers.
if(userList.Contains(username)) {
//check the time of message
//if last message is 3 seconds ago or greater, continue
} else {
//Add username & time into the array keeping all other values too
}
The problem is I don’t know how to append data into the array. I don’t know how to copy the other existing array data into the new array with the new values. Can this be done?
Since array.Contains() doesn’t work for two-dimensional arrays, what can I do to record the username and time? Should I insert data in two arrays?
Thank you for the help.
Arrays in C# are fixed size structures.
You want either a “List” which will allow you to implement this as a First In First Out queue, or, a “Dictionary” if you want to delete and insert at random.
Both these structures will allocate storage dynamically and allow you to expand and contract the number of users.