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 8208197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:15:30+00:00 2026-06-07T09:15:30+00:00

I have an empty list accepting string values. When an element will be added

  • 0

I have an empty list accepting string values.

When an element will be added I need to check if a string with the same value already exist in the list, if yes an exception should occur (ROLE 1 only unique value in the array).

Now I would like a user lets edit element in the list, if the new edited value is unique fine, otherwise an exception should occur.

My problem is: let’s imagine the user select the edit element but actually does not change the value when sending to the server. The system should detect that the element has not being changed and accept the value (even if is already present in the list).

PS I simplificate the problem, I’m actually using MVC and EF & linq. My problem is that I cannot check if the value inserted has been edited or not in the interface of my application.

Could you help me out to find an effective algo to solve this problem? Thanks

Let me know if the question is enough clear or you need more information

  • 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-06-07T09:15:31+00:00Added an answer on June 7, 2026 at 9:15 am

    This is my solution:

    1. Let the client check if the text was modified. If not, tell the server there was no modification. If this is not possible have the client send both the orinigial text and the modified text, and then the server will be able to check if it was modified. (if it wasn’t then there is no need to touch the data you are storing). This applies for both desktop and web enviroments.

    2. Preferibly don’t use a list, use a set (may be a hashset). The set will only allow to have each item once. In case you can’t I guess you can continue using the list. If I understand correctly you are using a database, so if you could interface with the database engine directly instead of syncing the list (or set) your application will have a performance boost.

    3. Convert the edition of the list/set into a add-remove pair (instead of setting the item). Have it check if the list/set contains the new value before doing any modification. If the new value is already present then you can throw an exception or send a message to the client (or whatever is more appropiate for your enviroment).

    4. You may want to sync the access to your list/set, keep it simple: use a lock (Monitor). I would consider a read-write lock, but that is complicating things while you are learning. [If you interface directly with the database engine, you can let it handle that instead]. Note: there is no need for this if you will only have one single client… ever (unless that single client can send multiple concurrent requests… :P).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this problem: starting from an empty list (0 elements) i want check
I have a problem with random and arrays. I have a list empty list
I have a list which is dynamically built, but there are empty list items
I have two ways of checking if a List is empty or not if
I have the following doubt concerning which exception to throw if list is empty
I have a list (tmpList), which looks like this: $op [1] empty $termset $termset$field
When I am writing for example Spring Bean I often have empty element without
I have an empty array into which I am pushing values using javascript. I
I have a method similar to this: public List<MyClass> DoSomething(string Name, string Address, string
I have an empty unordered list in my design. Now I want to add

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.