What is the code for it?
How will we add or remove object in a list
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
What is the code for it?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Tahir AnsariRank #366 · 6.8K reputationPosted Jul 28, 2023, 1:25 AM EDT
You can use a generic collection list to add or remove object below is a example:
List myList = new List(); myList.Add("Item 1"); // Adds "Item 1" to the list myList.Add("Item 2"); // Adds "Item 2" to the listList myList = new List { "Item 1", "Item 2", "Item 3" }; myList.Remove("Item 2"); // Removes the first occurrence of "Item 2" from the list