Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6062479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:03:24+00:00 2026-05-23T09:03:24+00:00

Dictionary class has TryGetValue List I guess has only Contains (doesn’t work based on

  • 0

Dictionary class has TryGetValue
List I guess has only Contains (doesn’t work based on indexes)

But this is not enough for how I do this..

when I add some kind of object to List.

I use list.IndexOf(objectJustAdded); to get index location of object.

In my server a client has same list and just sends the index of list to server thats how server accesses the object stored on list.

Now I’m trying to prevent ArgumentOutOfRangeException which I don’t think can happen, but I want to make server stable against hacker attack if someone sends malformed packet with bad index to list.. this exception may pop out.

What is best way to handle it? Try/Catch? anything better?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:03:25+00:00Added an answer on May 23, 2026 at 9:03 am

    If you’re going to loop through the indexes, you could do something like this:

    double removedCount = 0;
    for (int i = 0; i <= lst.Count - 1; i++) {
      lst.RemoveAt(i - removedCount);
      removedCount = removedCount + 1;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My class has a field of type Dictionary<string, List<string>> . What's the best way
My class contains a Dictionary<T, S> dict , and I want to expose a
I have a class derived from Dictionary. I need this class to simulate a
I created a class Entry to handle Dictionary entries, but in my main(), I
I have a class that has an internal list of other objects like so:
I have a base class that has the following property: public virtual Dictionary<String, int>
I have an Array list of a custom class which is essentially has two
In Python, I have a Graph class that has a dictionary of vertex objects.
One of my class has a property: Dictionary<int, MyObject> I get the error that
The class Item has a member function text() that returns a list of strings.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.